This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, 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 regards C Balajee
Yes, closing the connection closes the resultset and statement objects, since they both depend on the connection. ------------------ Bosun SCJP for the Java� 2 Platform
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Joined: Oct 18, 2000
You can try the following code in other JSP's or servlets.. session.getAttribute("email"); 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 requestObject.getSession(true/false) Hope this helps... regards C Balajee
Joined: Oct 18, 2000
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?? regards C Balajee
Note.. Disregard the previous post that was meant for a different thread..