Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating connection pool with web.xml <load-on-startup>

843854Jun 2 2002 — edited Apr 3 2003
This question is a continuation of an earlier post. Since this question is unrelated to the subject of that earlier post, I'm moving it here.

I repeat the initial question:

I suspect the problem is with the connection pooling. My application has multiple servlets. Every servlet has this identical block of code for creating the connection pool:

//********* Create Connection Pool ********************
Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
prop.setProperty(Context.PROVIDER_URL, "file:/JAVAFILES/JNDI");
Context ctx = new InitialContext(prop);
OracleConnectionPoolDataSource ocpds = (OracleConnectionPoolDataSource)ctx.lookup("AGI1");
PooledConnection pcon = ocpds.getPooledConnection();
Connection ocon = pcon.getConnection();
//********* End Create Connection Pool ****************

This code works. I've created a JNDI data source, which is a .bindings file created by running another class just once from the command line. I think the problem with this connection pool block of code is that I'm creating multiple connection pools when I'm supposed to create only one connection pool with multiple connections. My theory is that I should only have to run this block of code once in some sort of initialization servlet, and then I would only need these two lines:

PooledConnection pcon = ocpds.getPooledConnection();
Connection ocon = pcon.getConnection();

in all of my other servlets. I've tried to make this work, but it doesn't, probably because I'm not setting it up right.

Any suggestions you may have will be greatly appreciated.

Logan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2003
Added on Jun 2 2002
11 comments
374 views