File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Connection Release..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connection Release....." Watch "Connection Release....." New topic

Connection Release.....

C Balajee

Joined: Oct 18, 2000
Posts: 25
I have this following query ...
I have a Connection wrapper class which when instantiated gets a connection from a datasource and stores it into a class level variable.
Throughout the lenghth of my transaction i use this connection to execute my database queries.
I have also written a wrapper for the "Resultset" Generated from execution of a query. This class takes "java.sql.ResultSet" object in its constructor and stores it into a "class level variable" and thyen retreives data from the resultset to populate an hash table.
Now the problem is
As my transaction is completed i close the connection in my connection wrapper class by and explicit call to the "close()" method of the connection object.
But the resultset wrapper that i created early still resides in the memory and so does the "class level reference" to the resultset object.
Now i want to ask
If by closing the connection do i effectively close the resultset object too?(Eventhough there are references still in the memory to it)
If so then the connection now needs to be released?
But if i look at my database server i see that no connection is released..... And this leads to a shortage of connections and no further connections are available to me.(Eventhough no work is currently going on.).
Does the references to the resultset object create these problems???
looking for ward to any help and suggestions
C Balajee
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Yes, closing the connection closes the resultset and statement objects, since they both depend on the connection.
SCJP for the Java� 2 Platform

So much trouble in the world -- Bob Marley
C Balajee

Joined: Oct 18, 2000
Posts: 25
You can try the following code in other JSP's or servlets..
this will return an object which you need to cast to your connection pool.
the variable "session" is readily available with JSP Pages..
But in servlet you need to call
Hope this helps...
C Balajee
C Balajee

Joined: Oct 18, 2000
Posts: 25
Hi Bosun,
I also aggree that closing the conection will in turn close the statement and the resultset.
By "closing" you must mean that that the particular statement/resultset is not available for further use..
My query is what will happen if a reference to the closed resultset still exists in the memory..??
Will the connection pool manager of WebSphere release the connection for further use??
C Balajee

Disregard the previous post that was meant for a different thread..
I agree. Here's the link:
subject: Connection Release.....
It's not a secret anymore!