aspose file tools*
The moose likes JDBC and the fly likes Result Set Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Result Set Problem" Watch "Result Set Problem" New topic
Author

Result Set Problem

kundana sharma
Greenhorn

Joined: Sep 09, 2012
Posts: 10
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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Can you show us the exception message?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3437
    
  47

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

Joined: Sep 09, 2012
Posts: 10
Thanks Martin. e.printStackTrace() helped.I didn't iterate through ResultSet.I fixed it.
Will get back If some problem arises.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Result Set Problem
 
Similar Threads
Tokenizing a line and searching
invalid column index
Help with writing a program that gets student information from the user (Lengthy Post)
Polymorphism and HashMap problem
Problem with the query in JDBC ,resultset empty