Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in implementing connection pooling in tomcat6.0

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, I am chaitanya, since few days I am struggling on how to establish connection pooling with tomcat6.0 and mysql4.1. I have searched may forums and web sites. I gathered some information and started connection pooling. But all my efforts went into vain. I am providing the my code. Please correct me where I am wrong.

This code went into server.xml

This code went into my application's web.xml file


After configuring server.xml and my web.xml I placed two copies of the mysql driver jar in my alpplication's lib folder and server's lib folder. Next the necessary class file was placed in classes folder under WEB-INF folder.
This is the listener class MyConnectionListener.java

This is my jsp page which tries to connect to the database using pooling.

When I try to execute this I am getting the following error.


Can anybody please help me. Can anybody post me a sample application which implements connection pooling. I have referred this site for help. Connection pooling

Thank you all in advance.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open server.xml and look for the "/ConnectionPooling" context. Do you find several of them ? Remove unwanted ones. I think it would even look better to remove that from server.xml, and make your own context file under /conf/Catalina/localhost.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently you are attempting to publish multiple webapps under the context name of /ConnectionPooling. Each deployed webapp in Tomcat must have a unique context name, since that's how the URLs get routed to specific webapps. So you need to find and remove the duplicates from wherever they are.

For what you're doing you really shouldn't be modifying server.xml at all. For several years now, that's been discouraged, since it has significant disadvantages. It's better to make context XML files in $TOMCAT_HOME/conf/Catalina/localhost. DON'T attempt to define a context in both server.xml and conf/catalina/localhost, since Tomcat treats them as though they were all one big file, and that will give you a "duplicate context name" error.

If you're using that infernal useless Eclipse WST web plugin, it WILL muck with server.xml, but you shouldn't. Neither should they, technically, but they insist that they want to be compatible with Tomcat 3, even though even Tomcat 4 went end-of-life years ago.

Also, JDBC drivers should be placed in the Tomcat lib directory and NOT in the WAR. If you put a driver jar in both places, you may end up with classpath problems.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christophe, hi Tim, thanks for helping me. But I didn't understand anything, and I am a beginner in connection pooling, I have read a lot, I understood what the concept is, but unable to implement. Please can you give me a link where I can learn this?

Thank you in advance.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody for your help, I have done it.
I referred this site: click here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic