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

Resultset Parsing.

Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
Hi All,

In the ResultSet I have the results of a query execution.
The ResultSet will not have column names as it is a read from the
DB2 database. So I have used getString(1) types...

Now for the same row, I need to read the value of the same column twice.
If I give getString(2) two times in the same loop, it is throwing
an exception.

Appreciate any help on how this can be done, apart from the
scrollable resultset thing.

Thanks in advance
Sunil Kumar Gupta
Ranch Hand

Joined: Aug 26, 2005
Posts: 824
Just put the value of getString(2) in a String and second

time just read the String variable..No need to call

getString() again..


Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

What exception did you get ???

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Rajesh Agarwal
Ranch Hand

Joined: Aug 01, 2005
Posts: 79
Sunil,

Assume that I know all that, is there a way using JDBC.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Rajesh,
Your choices are:
1) Use a different driver - probably not practical for you
2) Return the column twice in the select clause - this is inefficient
3) Try using getString("name") - probably has same issue
4) Store as local variable as Sunil suggested

I recommend going with choice #4. It protects you against any other driver oddities that may arise.

What is the reason you don't want a local variable? JDBC is very closely tied to Java anyway.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resultset Parsing.