Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PooledConnection

Re: PooledConnection

From: Tom Vanstraelen <x_at_hotmail.com>
Date: Tue, 16 Oct 2001 18:03:07 +0200
Message-ID: <9qhlkl$72n$1@vg170.it.volvo.se>


Hi Chris,

If you close the Connection, it means that only the logical connection is closed, not the physical connection to the database. You have to close the PooledConnection to close the physical connection to the database.

Remark also that a PooledConnection will not give you a pool of connections despite the name.

From the documentation : "A pooled connection instance will typically be asked to produce a series of connection instances during its existence, but only one of these connection instances can be open at any particular time."

So you cannot set the pool size for a PooledConnection, look at the OracleConnectionCacheImpl class instead.

HTH,
Tom Vanstraelen

"Chris" <chris.lo_at_cyberwisdom.net> wrote
> I am writing an servlet program that use Oracle's connection pooling. Whe
> the servlet initilize, it will create an OracleConnectionPoolDataSource
and
> a PooledConnection which become static variables. For each request, I open
a
> database connection by using the PooledConnection and close the connection
> after the completion of the request. However, I found that some request
> didn't release the connection.
>
> Can I set the connection pool size and the timeout of each connection? Am
I
> right to do the following coding? Thanks.
>
> Chris
>
>
> --- myServlet.java ------
>
> import java.......
> .....
>
> public static PooledConnection pc = null;
>
> public class myServlet extends HttpServlet
> {
> void init(...) {
> OracleConnectionPoolDataSource ocpds = new
> OracleConnectionPoolDataSource();
>
> // Set connection parameters
> ocpds.setURL("jdbc:oracle:thin:@"+ dbHost + ":" +
dbPort
> + ":" + dbName);
> ocpds.setUser(usrNm);
> ocpds.setPassword(usrPw);
>
> pc = ocpds.getPooledConnection();
> }
>
> void service(...) {
> Connection con = pc.getConnection();
> // do some database action
> .....
> finally {
> con.close();
> }
> }
> }
>
Received on Tue Oct 16 2001 - 11:03:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US