Hi all,
This may be repeated question, but I could not find any satisfying solution to my problem in previous solutions.
i m working on developing a web application and want to implement database pooling.
Server::
Tomcat 5.0
DB:: mysql 4.0
I deploy and undeploy my application using tomcat manager,
hence i donot have the <Context> element configured in the server.xml
For database pooling, I used the element <GlobalNamingResources>
After these settings, the Tomcat Admin shows the Data Source Created with name jdbc/MyappDB
When I run the application and hit the url where the database connection is obtained, I get the following error::
org.apache.commons.dbcp.SQLNestedException: Cannot create
JDBC driver of class '' for connect URL 'null', cause: No suitable driver
Can somebody help me on this ?
Basically the question here is that, if the <Context> element is not used, what web.xml setting have to be made to access this Data source in Global area.
Note: the <Context> element have the element <ResourceLink> to access such global resources.
Following is my settings.
/********************************/
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<Resource name="jdbc/MyappDB" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyappDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>admin</value>
</parameter>
<parameter>
<name>password</name>
<value>admin123</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/myapp?autoReconnect=true</value>
/parameter>
</ResourceParams>
</GlobalNamingResources>
/*******************************///
web.xml settings..
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MyappDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
/*******************///