• 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

Result Set Problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a table called Student whose structure is like this
ID (PK) (Number) | Name (varchar2) | Class (number) |
I am connecting to a remote Oracle db.\

My Question: an SQL exception when it comes to line no 19.(when I debug the cursor jumps to line no 26 from 19 )I am not able to figure out what is happening.
I know that there is problem with result set,but I am not able to fix it.
thank you in advance.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us the exception message?
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use e.printStackTrace() in your catch clause. That way you'll see much more information about the exception. It might even help you figure out what's going on. (In production code, you should set up a logging system in your app and write diagnostic messages (and exceptions) to the log.)

The problem is that when you open a resultset, the current position points to a position just before the first row. So there is no current row and you cannot access its fields. After opening a resultset, you need to call next(). If the first call to next() return false, there were no rows returned by your query.

I'd suggest reading the JDBC tutorial, if you haven't done so yet. It is a very good introduction into JDBC.
 
kundana sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Martin. e.printStackTrace() helped.I didn't iterate through ResultSet.I fixed it.
Will get back If some problem arises.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic