⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatetime.java

📁 获取当前系统时间,然后向后或向前多少天时间
💻 JAVA
字号:
package com.jspsoure.Haikou;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import javax.swing.border.TitledBorder;
import java.sql.*;
import java.io.*;
class UpdateTime
{
   public UpdateTime()
   {
   }
   public String select(Integer index)
   {
   	 String  catType1="";
   	try
   	 {
   	 	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	    Connection  con=DriverManager.getConnection("jdbc:odbc:jspsoure","sa","sa");
	    Statement statement=con.createStatement();
	    String sqlsc="select carType from Haikou where index1="+index+"";
	    //System.out.println(sqlsc);
	    ResultSet rs=statement.executeQuery(sqlsc);
	    while(rs.next())
	    {
	      catType1=rs.getString("carType");	
	    }
	    statement.close();
	    con.close();	
   	 }
   	  catch(Exception e)
      { 
         e.printStackTrace();
      }
      return catType1;
   }
   public UpdateTime(String currentTime1,String updateSTTime,String updateSPTime,String carType,String currentDate,int index)
   {
	  
	  
	  try
	  {
	    //装载数据库驱动程序
	    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	    Connection  con=DriverManager.getConnection("jdbc:odbc:jspsoure","sa","sa");
	    Statement statement=con.createStatement();
	    //更新三亚昨天的数据作为当天的班次
	    String sql="update Haikou set startTime='"+updateSTTime+"',stopTime='"+updateSPTime+"',date='"+currentDate+"'"+ 
	    "where carType='"+carType+"'" +
	    "and ((startTime>'"+currentTime1+"'"+
	    "or startTime<'"+currentTime1+"')"+
	    "and date<'"+currentDate+"'"+
	    "and (stopStation='三亚' or stopStation='东方八所' or stopStation='琼海加积')"+
	    "and index1="+index+")";
	    statement.executeUpdate(sql);
	     
	    //更新比当前时间大的三亚班次
	    String sql1="update Haikou set startTime='"+updateSTTime+"',stopTime='"+updateSPTime+"',date='"+currentDate+"'"+ 
	    "where carType='"+carType+"'" +
	     "and (startTime<'"+currentTime1+"'"+
	     "and date='"+currentDate+"'"+
	     "and (stopStation='三亚' or stopStation='东方八所' or stopStation='琼海加积')"+
	     "and index1="+index+")";
	   //System.out.println(sql1);
	    statement.executeUpdate(sql1);
	    statement.close();
	    con.close();	
	    
	  }
	  catch(Exception e)
      { 
         e.printStackTrace();
      }
       
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -