Home >Database >Mysql Tutorial >关于JDBC不支持ResultSet.last()等方法的解决

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:14:421848browse

现象:使用微软的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 对象的类型。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:高校的项目就是水啊操Next article:JVM指令2