Connection Pooling - how to close properly?? PLEASE HELP!

I am very confused about something and cannot find a clear answer within the Oracle docs or Sun's Java docs. When using connection pooling, you create an OracleConnectionPoolDataSource, obtain a PooledConnection, then a JDBC Connection (this is fine). But when finished, you close the JDBC Connection, but what about the PooledConnection? Do you close this too? Or do you just leave it and let it get garbage collected? Is the implementation smart enough to release/reuse PooledConnections when the underlying JDBC Connection is closed? It seems to me that if you close the PooledConnection too, then how/when does the pooling come into place? How/where are the pool parameters (max num of connections) controlled? Please Help! Thank you!

I have implemented a pooled JDBC connection & driver in a large project. So I know something about this topic.
java.sql.* is only interface, that means this package needs implementation. Under an ordinary circumstance, a Connection is an Client/Server communication, when you call close() method, the communication is really closed, so next time, you should reinstantiate the client/server connection, passing authentication and authorization testing, this is a lot of load to the system; connection pool uses a different mechanism to try to save this load, that is, when you call close() method of Connection, the connection is not really closed, but just set a flag to tell the system this connection is available to others, so next time when you call DriverManager.getConnection(...), the available connection will be returned to the caller, and because this connection has already passed authentication and aothorization, the socker between is available, so the extra load could be saved, in other words, the application could use it immediately.
Check java.sql.Driver interface, you will see boolean acceptsURL(String url) and java.sql.Connection connect(String url, java.util.Properties info) methods, first method is used by DriverManager to judge which JDBC driver should be used according to your connection's url format, then that driver's connect(...) method will be called to return an connection. For pooled connection, when you call connection.close() method, the Connection object is not garbage collected but return a pooled connection manager or repository, so it could be reused by other application.
Hope this helps.
//jdev

Similar Messages

Maybe you are looking for

  • How to create new page in SAP Script?

    Moved to correct forum by moderator.  Duplicate deleted.  Do NOT post the same question in two forums. Hello friends, I am modifying one SAP script. It is already contains 2 pages. FIRST and NEXT. All I have to do is to create one more page which sho

  • How to optimize GUI_DOWNLOAD function I am using...

    Hi, I have got 54 internal tables populated at the end of the report. I am using GUI_DOWNLOAD Function to download the data in flat files each corresponding to one internal table. Now in GUI_DOWNLOAD Function, I know I have to mention name of file an

  • Home sharing blinks off

    Hello folks, I have upgraded iTunes to 10.6 and planned to use home sharing but as soon as I authorise my PC and authorise iTunes By logging by apple id. Home sharing option simply goes away. Just like a blip and it's gone... OS: XP

  • Time code written in the audiotrack

    Dear users, i have FCP and i am going to work with the camere van Silicon Image. the SI2K. this one has no timecode reading of 25. european standard, it only has american standards. so now we thought lets write the timecode in the audio track. this r

  • Apps on dock??

    I assume there's no way of creating a apps folder icon on the dock?? i keep trying to drag the apps icon onto the dock but alas...