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 -> PooledConnection

PooledConnection

From: Chris <chris.lo_at_cyberwisdom.net>
Date: Mon, 15 Oct 2001 21:47:34 +0800
Message-ID: <9qeods$ug2$1@tenorhorn.hk.dyxnet.com>


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

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 Mon Oct 15 2001 - 08:47:34 CDT

Original text of this message

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