• 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

No Exception for ResultSet TYPE_FORWARD_ONLY

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my code example. I am expecting an exception that indicates that the ResultSet is TYPE_FORWARD_ONLY but I get none. I am using MySQL DB with Type 4 Driver.
Right now I get the contents of the contacts table printed twice with no exceptions.
JavaDoc says

Statement createStatement() throws SQLException
Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.


What am I missing here?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you examined the ResultSet to see what its type actually is? I haven't looked, but I expect there must be a method which you can call to find out.
 
Rahul Shinde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added the getType() method on the ResultSet to print that.
It says "Type = 1003"

ResultSet.java says

int TYPE_FORWARD_ONLY = 1003;


 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say that the resultset type determines the minimum capabilities of the resultset. In this case, the authors of the JDBC driver probably saved themselves some work by not implementing the forward only type, and used the more capable one instead. In correctly coded applications this shouldn't lead to problems. You might get a problem if you tested your application with a different JDBC driver than the one actually used in production (by not catching this bug in test and having it appear only in production, for example) - however, it is always advisable to match the test environment as closely to the production environment as possible.
 
reply
    Bookmark Topic Watch Topic
  • New Topic