HI TO ALL, here i want to execute 2 query's using same connection and same statement and resulset. is there anything wrong in this issue? should i need to do create seperate connections and stmt and result for both query's
thanx in advace cinux [ April 01, 2006: Message edited by: Ernest Friedman-Hill ]
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
Using the same connection is of course fine, but you create the statement with the query, and the result set is created by executing the statement. So for the last two it cannot be the same. If you mean using the same variables, then yeah, no problem, but the items will not be "concatenated" or any such stuff. The variables will have one value (or set of values) for one query, and be completely different (new) items with the second query.
before the second query string I would place a rs.close( ) and stmt.close( ) as well as another stmt = con.createStatement( ) just to be sure. As far as reusing the variables no problem. Don't worry about the "extra" lines of code or the extra actions involved. An additional time needed to accomplish these are truely nominal.
Joined: Sep 29, 2002
The code looks as if it should work.
As you are creating two Resultset objects, then ensure that you close both.