当前位置: 技术问答>java相关
用jdbc-odbc 连excel的时候。为什么总是提示要可更新的
来源: 互联网 发布时间:2015-03-21
本文导语: 程序片断如下。 在运行倒exceuteupdate,的时候就提示我要可更新的结果集 public static String DRIVER_NAME = "sun.jdbc.odbc.JdbcOdbcDriver"; public static String DATABASE_URL = "jdbc:odbc:user"; public execldemo() { }...
程序片断如下。
在运行倒exceuteupdate,的时候就提示我要可更新的结果集
public static String DRIVER_NAME =
"sun.jdbc.odbc.JdbcOdbcDriver";
public static String DATABASE_URL = "jdbc:odbc:user";
public execldemo() {
}
public static void main(String[] args)
throws ClassNotFoundException,SQLException{
Class.forName(DRIVER_NAME);
Connection con = null;
try {
con = DriverManager.getConnection(DATABASE_URL);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
int a=stmt.executeUpdate ("update [user$] set password='aa' ");
ResultSet rs = stmt.executeQuery ("select * from [user$]");
while (rs.next()) {
String lname = rs.getString(0);
String fname = rs.getString(1);
System.out.println(fname + " " + lname );
}
rs.close();
stmt.close();
}
catch(SQLException e){
throw e;
}
finally {
if (con != null)
con.close();
}
}
在运行倒exceuteupdate,的时候就提示我要可更新的结果集
public static String DRIVER_NAME =
"sun.jdbc.odbc.JdbcOdbcDriver";
public static String DATABASE_URL = "jdbc:odbc:user";
public execldemo() {
}
public static void main(String[] args)
throws ClassNotFoundException,SQLException{
Class.forName(DRIVER_NAME);
Connection con = null;
try {
con = DriverManager.getConnection(DATABASE_URL);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
int a=stmt.executeUpdate ("update [user$] set password='aa' ");
ResultSet rs = stmt.executeQuery ("select * from [user$]");
while (rs.next()) {
String lname = rs.getString(0);
String fname = rs.getString(1);
System.out.println(fname + " " + lname );
}
rs.close();
stmt.close();
}
catch(SQLException e){
throw e;
}
finally {
if (con != null)
con.close();
}
}
|
;)
|
怎么解决的,可否共享一下了,我的代码里无法执行ExcuteUpdate(sql)??也就是对于update和delete 以及insert 无法执行,高手指点,一定给分!!!!!!!!!