当前位置: 技术问答>java相关
超郁闷问题,这个ResultSet怎么就是Read only的呢?
来源: 互联网 发布时间:2014-12-27
本文导语: 建立ResultSet的代码如下: DriverManger.registerDriver(new jdbc.oracle.driver.OracleDriver()); Connection DBCon = DriverManager.getConnection(X,X,X); Statement Stmt = DBCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ...
建立ResultSet的代码如下:
DriverManger.registerDriver(new jdbc.oracle.driver.OracleDriver());
Connection DBCon = DriverManager.getConnection(X,X,X);
Statement Stmt = DBCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet Result = Stmt.executeQuery("SELECT * FROM AA");
这样出来的ResultSet是Scrollable的,但是就是告诉我是个Read Only的。我用moveToInsertRow就报错。真是#¥@#%@%@#¥@#……
请大侠们帮个忙吧!!!!
ps:驱动是从OTN down的for jdk 1.2的驱动,应该是2.0版的jdbc吧?!
DriverManger.registerDriver(new jdbc.oracle.driver.OracleDriver());
Connection DBCon = DriverManager.getConnection(X,X,X);
Statement Stmt = DBCon.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet Result = Stmt.executeQuery("SELECT * FROM AA");
这样出来的ResultSet是Scrollable的,但是就是告诉我是个Read Only的。我用moveToInsertRow就报错。真是#¥@#%@%@#¥@#……
请大侠们帮个忙吧!!!!
ps:驱动是从OTN down的for jdk 1.2的驱动,应该是2.0版的jdbc吧?!
|
要看具体的数据库是否支持createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
比如Oracle 数据库就是这样的:
Oracle中可滚动的结果集有下列限制:
Support Type Concurrency
---------------------------------------------------------------- no TYPE_FORWARD_ONLY CONCUR_READ_ONLY
no TYPE_FORWARD_ONLY CONCUR_UPDATABLE
no TYPE_SCROLL_INSENSITIVE CONCUR_READ_ONLY
yes TYPE_SCROLL_INSENSITIVE CONCUR_UPDATABLE
yes TYPE_SCROLL_SENSITIVE CONCUR_READ_ONLY
yes TYPE_SCROLL_SENSITIVE CONCUR_UPDATABLE
----------------------------------------------------------------
ResultSet.CONCUR_UPDATABLE);
比如Oracle 数据库就是这样的:
Oracle中可滚动的结果集有下列限制:
Support Type Concurrency
---------------------------------------------------------------- no TYPE_FORWARD_ONLY CONCUR_READ_ONLY
no TYPE_FORWARD_ONLY CONCUR_UPDATABLE
no TYPE_SCROLL_INSENSITIVE CONCUR_READ_ONLY
yes TYPE_SCROLL_INSENSITIVE CONCUR_UPDATABLE
yes TYPE_SCROLL_SENSITIVE CONCUR_READ_ONLY
yes TYPE_SCROLL_SENSITIVE CONCUR_UPDATABLE
----------------------------------------------------------------
|
用DBcon.setReadOnly(false)方法可以将记录集设置为可写。
|
大多数JDBC Driver并不支持这些高级的功能,为了使你写的程序通用,建议还是用SQL语句增、删、改数据。
|
try
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE