File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet after DB closed

 
vishvar hariraman
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody

After closing the connection with a database,can we use the ResultSet object to manipulate the data? whether the data is available in ResultSet object or not?
Resultset and statement objects correspond to cursor position in the database,I suppose.We explicitly need to close these objects.So memory leaks are avoided.

If we close DB connection directly without closing statement and resultset objects,still do we have problem of memoryleak? pls friens clarify regarding this


THX
---VISHNUVARDHAN.H




 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vishvar hariraman:

After closing the connection with a database,can we use the ResultSet object to manipulate the data? whether the data is available in ResultSet object or not?




As per Javadoc


Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.



So once a connection is closed its JDBC resources are released, and you can not use them. If you try to use them you will get an exception.

And It is always a good practice to release the resources explicitly in your program.


Shailesh
[ April 05, 2006: Message edited by: Shailesh Chandra ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used one, but it sounds like you are talking about a disconnected RowSet.

On the other hand, the most common way to use a ResultSet is iterate through it, creating objects to hold a copy of the data of each row, placing these objects in an appropriate collection, say a List, then closing the ResultSet and working with this data.
 
Anantha Reddy.N
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:



So once a connection is closed its JDBC resources are released, and you can not use them. If you try to use them you will get an exception.

And It is always a good practice to release the resources explicitly in your program.


Shailesh

[ April 05, 2006: Message edited by: Shailesh Chandra ]



hi
ResultSet object is Connection Oriented, it is a pointer pointing to result area(rollback/commit segment on DB buffer), it alives as long as Connection object is alive, it will not accessbale after connection is get closed.

yes, u can achive this with disconnected RowSet..refer RowSet API.but it will work jdk1.5 onwords..
 
Anantha Reddy.N
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:



So once a connection is closed its JDBC resources are released, and you can not use them. If you try to use them you will get an exception.

And It is always a good practice to release the resources explicitly in your program.


Shailesh

[ April 05, 2006: Message edited by: Shailesh Chandra ]



hi
ResultSet object is Connection Oriented, it is a pointer pointing to result area(rollback/commit segment on DB buffer), it alives as long as Connection object is alive, it will not accessbale after connection is get closed.

yes, u can achive this with disconnected RowSet..refer RowSet API.but it will work jdk1.5 onwords..

thanks
Ananth
 
vishvar hariraman
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx friens
Vishnuvardhan.H
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic