When you close a connection can you still use the resultset?
For example if I create a jdbc connection then create a PreparedStatment and execute the statement to get a resultset.
If I then close the jdbc connection can I still traverse and get the data of the resultset?
I am just wondering what the difference is in closing a resultset as opposed to closing the entire connection provided you never use more then one resultset per connection.
Is it better to create many jdbc connections and one resultset per connection or to use one jdbc connection and many recordset's?
I have JSP's pages that need to query a database but I am unsure if it is better to create a connection and store it in a Session varable so it is valid to all pages or to create a connection for each page.
Constantly geting a connection and closing a connection.
Also I have jsp functions that must return RecordSets and PreparedStatments but I am unsure if I can have these functions close the connection to the database before returning the RecordSet or PreparedStatment.
I am just worried about leaving unclosed connections dangling behind?
If I have a recordset in a page how can I close the jdbc connection that created the connection just from the knowledge of the recordset?
Because sometime I call a function to get the recordset when I close the recordset I don't want the connection to be open forever never being closed each time I call the function to get a resultset.
Sam Doder wrote:When you close a connection can you still use the resultset?
A connection, statement and resultset are to be acquired and closed in the shortest possible scope. If you need to pass the results out of the scope, then you need to map the desired results to a collection of row objects. Read on about the DAO pattern.