Although most of these answers are about pools, I don’t think your question is?
I think the most direct answer to your question is to simply import and use the DataSource implementation provided by your driver. Are you using MySQL Connector / J? then MysqlDataSource .
There are methods for setting a username, password, etc.
If you do not need it in JNDI, you do not need to configure it in JNDI via Tomcat. Of course, you can store the driver pitcher in WEB-INF / lib. If you want to unite around this DataSource, just use Commons DBCP and Pool.
Here's an example of creating your own DataSource union from a DataSource.
source
share