Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat Connection Pooling Help required

 
nitin kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
/*******************///
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitin,
This sounds like a classpath or Tomcat configuration issue. I'm going to move this to our Tomcat forum so you can get more help.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is your mysql driver jar file in the common/lib directory?
 
Nina Savannah
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitin Kumar, did you manage to find a solution for this problem?

I have the same specification and I am trying to do connection pooling, can you help?
 
Bhaskar Rao
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have had this issue earlier. This is a generic error and can be thrown for various reasons. Have you tried defining the context as either 'context.xml' or yourwebappname.xml ?

have a look at the following URLTomcat config
[ December 28, 2008: Message edited by: Bhaskar Rao ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic