好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

关于JDBC不支持ResultSet.last()等方法的解决

现象:使用微软的JDBC for SqlServer sp3却发现不 支持 ResultSet.last(),ResultSet.beforeFirst() 等 方法 ,每次一调用这些 方法 就出现异常,异常信息是:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: Result

现象:使用微软的JDBC for SqlServer sp3却发现不 支持 ResultSet.last(),ResultSet.beforeFirst() 等 方法 ,每次一调用这些 方法 就出现异常,异常信息是:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last

解决 :Statement变量要按照如下设置

stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE , ResultSet.CONCUR_UPDATABLE);

类似的,

CallableStatement cs = conn.prepareCall("{call TESTSP}",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

其中 type_scroll_sensitive 是个关键

字段摘要

TYPE_SCROLL_SENSITIVE

该常量指示可滚动但通常受其他的更改影响的 ResultSet 对象的类型。

查看更多关于关于JDBC不支持ResultSet.last()等方法的解决的详细内容...

  阅读:33次