Link to home
Start Free TrialLog in
Avatar of edc
edc

asked on

JDBC connection pool in non-enterprise bean

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.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of edc
edc

ASKER

Ah, fantastic.  Just what I was looking for.  Thanks.
:)

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 ;)
Avatar of edc

ASKER

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.
Careful - afaik the Tomcat cp has no connection with that
Avatar of edc

ASKER

Righteo.  :o)
Avatar of edc

ASKER

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).
Yes, i think the Connector-J supports pooling, but i'm not sure it pools without prior configuration
Avatar of edc

ASKER

Ah, more investigation then :)
afaicr the Connector-J pool seemed to lack documentation, in contrast to the Tomcat one