This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a single Statement object for whole of my application i want to know that when i got a ResultSet object after executeQuery() mehtod and then again used the Statement object for another executeQuery() mehtod that again returned a ResultSet object , would the first ResultSet object become unusable or not.
The way that a driver behaves is dependant on the drivers implementation of the Statement Interface. But in general it usually has 1 of the following 2 behaviours: The code:
Driver behaviour #1 (eg. odbc:jdbc bridge) The maximum number of resultsets to a statement is 1. Thus, when resultset 'r2' is created, the statement closes the previously associated resultset(r1) before it proceeds to execute the query for r2. This is why an exception is thrown when you try to access r1 again after it has been closed. Driver Behaviour #2 (eg. Oracle drivers) The maximum number of resultsets to a statement object is undefined. I've used up to 7 resultsets on one statement object. So, the code posted above would work. When you create resultset r2, r1 remains untouched. No exceptions are thrown. you have to find out in your documentation or by trial and error which type your's is Jamie ps. the same can be said for Connections to Statements.
Joined: Feb 24, 2001
thanks Jamie for ur help i will surely try it .well i am using jdbc dbc bridge for MS SQL server 7.0 .i will check does it work for type 1 according to u or not.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Can we use the Statement object for multiple ResultSet objects?