File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes a problem about read only ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "a problem about read only ResultSet" Watch "a problem about read only ResultSet" New topic

a problem about read only ResultSet

Baijun Jiang

Joined: Oct 13, 2005
Posts: 17
I have java codes like this:

String sql="select energy_etc.kwhexp from ...";
Statement kwhexp_stmt = conn.createStatement
ResultSet kwhexp_rs = kwhexp_stmt.executeQuery( sql);
double d=1.1;

When I execute these codes I got a error message:
Exception in thread "main" java.sql.SQLException: Invalid operation for read onl
y resultset: updateDouble
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.driver.BaseResultSet.updateDouble(
at oracle.jdbc.driver.OracleResultSet.updateDouble(
at MonthlyBillGeneration.main(

What could be the reason I cannot update my result set?

Ram Mohan

Joined: Oct 21, 2005
Posts: 26
I didn't find anything wrong in your codes.
May some one help you.

Ram Mohan
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Just because you asked for an updateable cursor doesn't mean you got one. The database is giving you a read only cursor for any/all of the following reasons:

- just not supported
- you haven't selected the tables primary key as part of your select
- the query has a joing
- the database doesn't support a cursor that is BOTH updatable and scrollable

If you add the primary key field to your query and it still doesn't work then you need to consult the documentation for your database as to when you get which type of cursor. Again not all cursor modes are supported by all databases in all circumstances. So there is something about your request that isn't supported and you'll have to find out what.
I agree. Here's the link:
subject: a problem about read only ResultSet
It's not a secret anymore!