We help IT Professionals succeed at work.

JDBC connection pool in non-enterprise bean

edc
edc asked
on
Hello all,
I have a java class file which is not part of an EJB or servlet.  I would like to have database connection pooling from this class. Currently it is connecting to MySql, but there will be other DBMSs later.  

The only information I have found for database connection pooling is in the context of an EJB or servlet using JNDI.

Would someone guide me through accomplishing database connection pooling from a non enterprise bean?

Thanks.
Comment
Watch Question

Top Expert 2016
Commented:
http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html

is able to operate in a standalone manner, outside a web app context
edc

Author

Commented:
Ah, fantastic.  Just what I was looking for.  Thanks.
Top Expert 2016

Commented:
:)

It would be very useful if you could post something back here to let us know how you get on. afaik this is newish, so you're probably so far in a relatively small number of people using this ;)
edc

Author

Commented:
Yeah, absolutely. I'm pulling down the apache commons dbcp jar.  It looks like it has been build for this, but I will know more when I try it out.
Top Expert 2016

Commented:
Careful - afaik the Tomcat cp has no connection with that
edc

Author

Commented:
Righteo.  :o)
edc

Author

Commented:
It looks like I was making this far more complicated that it actually was.  There is a method within the JDBC driver named getConnection()  That will give you a connection to a connection pool without the need for outside libraries (at least in MySql it does).
Top Expert 2016

Commented:
Yes, i think the Connector-J supports pooling, but i'm not sure it pools without prior configuration
edc

Author

Commented:
Ah, more investigation then :)
Top Expert 2016

Commented:
afaicr the Connector-J pool seemed to lack documentation, in contrast to the Tomcat one