• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a problem about read only ResultSet

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have java codes like this:

String sql="select energy_etc.kwhexp from ...";
System.out.println(sql);
Statement kwhexp_stmt = conn.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet kwhexp_rs = kwhexp_stmt.executeQuery( sql);
double d=1.1;
while(kwhexp_rs.next()){
kwhexp_rs.updateDouble("kwhexp",d);
kwhexp_rs.updateRow();
d++;
}

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(DBError.java:187)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
at oracle.jdbc.driver.BaseResultSet.updateDouble(BaseResultSet.java:225)
at oracle.jdbc.driver.OracleResultSet.updateDouble(OracleResultSet.java:2816)
at MonthlyBillGeneration.main(MonthlyBillGeneration.java:34)


What could be the reason I cannot update my result set?
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't find anything wrong in your codes.
May some one help you.

Ram Mohan
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic