+3  A: 

Set up the database connection pool or resource and make it available via JNDI. You can use spring to configure the connection string if you don't have an application container. If you do, for example in glassfish, you can setup your database resources and connection pools and assign them jndi names from the admin console. These will then be easily retrievable from your application if you make the jndi name well known.

John Ellinwood
+1  A: 

Look at Commons DBCP:

http://commons.apache.org/dbcp/

this will give you connection pooling, and like mentioned you can then stuff the information in JNDI - this is how Tomcat works.

Jon