终于搞定了,,可以下班了

微软的jdbc驱动太烂了,以后用jtds

 

 

错误原因:数据库里面有text型或者image之后,不按照顺序取值会报错!

 

错误代码:ResultSet can not re-read row data for column

 

 

解决方案: stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

 

更新jdbc包换为jtds

 

数据库代码:

 

public class ConnDatabase {

 String jdbcDriver;
 String connURL;
 String userName;
 String passWord;
 Statement stmt;
 ResultSet res;
 Connection con;
 public ConnDatabase(){
  jdbcDriver = "net.sourceforge.jtds.jdbc.Driver";
  connURL = "jdbc:jtds:sqlserver://localhost:1433/cspc4java";
  userName = "sa";
  passWord = "sa";
 }
 public Statement connData(){
  
  try{
   Class.forName(jdbcDriver);
   con = DriverManager.getConnection(connURL, userName, passWord);
   stmt = con.createStatement();
   
  }catch(Exception e){
   e.printStackTrace();
  }
  return stmt;
 }

}

你可能感兴趣的:(终于搞定了,,可以下班了)