| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> PooledConnection
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();
}
![]() |
![]() |