加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

DATETIME

发布时间:2020-12-12 15:27:27 所属栏目:MsSql教程 来源:网络整理
导读: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.SQLServerDriv

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读