数据库测试代码

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=uep", "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");
   //ResultSet rs ;
   for(int i= 0;i<1000000;i++)
   {
   sql = con.prepareStatement("insert into uep.dbo.bb_experiment (index_int ,varchar_)values (9,'a')");
//   executeQuery(sql);
   sql.execute();
   //ResultSet rs =sql.executeQuery();
   
   
   }
   System.out.println("ok");
//   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");
  }
  
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值