aspose file tools
The moose likes JDBC and the fly likes can you execute a query while processing results Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "can you execute a query while processing results" Watch "can you execute a query while processing results" New topic
Author

can you execute a query while processing results

Robert Johnson
Ranch Hand

Joined: Feb 11, 2005
Posts: 32
can you execute a query in the while loop of a different resultSet?
e.g.,...



it only works once, it stops at the end of the while loop, i.e., it doesnt loop around the resultSet like it should.

[edited to add code tags and change "u" to "you"]
[ March 24, 2005: Message edited by: Jeanne Boyarsky ]

Whats in a name?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26496
    
  78

Robert,
Executing the update on stmt indirectly closes the select query also using the stmt object. If you use a different Statement object, the problem will go away.

Also, you should consider using a PreparedStatement here. Especially since the update is occuring in a loop.


[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
Robert Johnson
Ranch Hand

Joined: Feb 11, 2005
Posts: 32
ok, thanks i'll try that.

i would have thought it wouldnt need the statment object as i thought it just used it once and then loop around the resultSet only.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can you execute a query while processing results
 
Similar Threads
how to remove '\n' and '\r' in the file by kshell
Newbie question... :(
doubt in loop
Why do these queries break this loop????? Im lost!
Help with empty result set