package FS; import java.sql.*;
public class UpdateStu {
?static Connection con; ?static PreparedStatement sql; ?static ResultSet res; ?public Connection getConnection() { ??try { ???Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); ???con = DriverManager.getConnection( ?????"jdbc:microsoft:sqlserver://localhost:1433;" ???????+ "DatabaseName=newdb","sa","data"); ??} catch (Exception e) { ???e.printStackTrace(); ??} ??return con; ?} ?public static void main(String[] args) { ??UpdateStu c = new UpdateStu(); ??con = c.getConnection(); ??try { //???sql = con.prepareStatement("delete from newtable where birthday < ?"); //???sql.setString(1,"2000-09-01"); //???sql.executeUpdate(); ?//??sql = con.prepareStatement("select * from uep.dbo.A_experiment"); ??//?String sql = "select * from uep.dbo.A_experiment"; ???sql = con.prepareStatement("select * from uep.dbo.A_experiment"); //???executeQuery(sql); ???ResultSet rs =sql.executeQuery(); ???while (rs.next()) ???{? //????for(int i =0;i<17;i++) //????{ //????String result = rs.getString(i+1); //????System.out.println(result); //????}
???//rs.getDate(13);????????Date date = rs.getDate(5);????System.out.println(date);????date.getYear();????date.getMonth();???System.out.println(date.getYear());???System.out.println(date.getMonth());???System.out.println(date.getDay());//???System.out.println(date.getHours());//???System.out.println(date.getMinutes());//???System.out.println(date.getSeconds());???}??} catch (SQLException e) {???// TODO 自动生成 catch 块???e.printStackTrace();???System.out.println("fail");??}???}}
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|