?? updatetime.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
{
//裝載數(shù)據(jù)庫驅(qū)動程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:jspsoure","sa","sa");
Statement statement=con.createStatement();
//更新三亞昨天的數(shù)據(jù)作為當(dāng)天的班次
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);
//更新比當(dāng)前時間大的三亞班次
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();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -