微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

DATETIME

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");  }   }}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐