Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to your Context.
so should i place
<!-- maxActive: Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to -1 for no limit.
<!-- maxIdle: Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
<!-- maxWait: Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
<!-- username and password: MySQL dB username and password for dB connections -->
<!-- driverClassName: Class name for the old mm.mysql JDBC driver is
org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.
<!-- url: The JDBC connection url for connecting to your MySQL dB.
Tomcat itself doesn't do database connection pooling. It supports plugin poolers. The Apache DBCP pooler is provided as part of the Tomcat distro, however, so that eliminates the need for you to download and install a separate connection pooler unless you really want to.
To the best of my recollection, the same configuration instructions apply for connection poolers (DataSources) for Tomcat 3 all the way up to Tomcat 7 and the instructions on the tomcat.apache.org website are pretty clear, I think.
To create, configure, and use a database connection pooler, you define the datasource(s) in your webapp context definition or in the global server config. That definition specifies the location of the database of interest (URL), its connection credentials and parameters, and whatever pool tuning and diagnostic options you wish to employ. It also binds the DataSource to a jndi name so that the webapp(s) can locate it by an abstract identifier rather than by having to supply specifics within the webapp itself.
In the webapp, you set up a resource-ref in web.xml. The you use JNDI to locate the DataSource whenever you wish. You can do this at startup and cache the DataSource object for later use if you prefer to reduce the JNDI overhead.
An app may employ multiple DataSources. Normally you'd want all connections to a specific database to use the same connection pool, but I have several apps that connect to multiple databases, so each database has a corresponding DataSource.
An IDE is no substitute for an Intelligent Developer.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com