JDBC中的一些问题!

来源:互联网 发布:什么交友软件好 编辑:程序博客网 时间:2024/04/29 10:39

com.mysql.jdbc.NotUpdatable: Result Set not updatable (referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE,the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.

大概是说:ResultSet对象中没有更新这个功能。要想让resultset对象拥有这个功能,那就必须在其创建statement对象,指定某些功能加进去。

具体的做法是:

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

那就行了。

 

com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table,
can not use functions and must select all primary keys from that table.See the JDBC 2.1 API Specification, section 5.6 for more details.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE,the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.

如果第一个问题已经解决了,还出现上面的问题,那就是说该数据表中的字段值没有primary key。所以必须要修改其数据表结构。

 

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
 at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
 at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
 at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
 at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at JDBC.SQLDemo.main(SQLDemo.java:20

当出现上面的问题时,说明我现在安装SQLServer2000还没有升级,现在我去下载补丁SP4。安装SP4,相当于把其相关文件解压放入某个目录下。然后,双击安装目录下文件夹里的“setup.bat”文件,才开始真正安装SP4补丁文件。升级成功安装后。运行JDBC可成功的与数据库连接。