This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection Pooling Problem

 
Nina Savannah
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone please please help me with my connection pooling? I have been trying for a while now with no success.
Below is my jsp file that I use for my database connection.
I need someone to help me with the codes that will make this file implement connection pooling.

Your help shall be very much appreciated.

I have edited web.xml and server.xml



 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters: do not write Java code in JSP files. Write Java code in Java classes. Doing so in JSP is receipt for trouble.

To use connection pooling, just create a datasource in the application server get a connection from it and handle it the usual way (acquire and close connection/statement/resultset in the shortest possible scope in a try/finally block). How to create a datasource is covered in the documentaiton which came along with the appserver in question. If it is for example Tomcat, you can find here such a document: http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
 
Nina Savannah
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your response. Here is what I have done
I added the in C:\Tomcat\conf

web.xml





server.xml





Now this is far as I can go. I am a beginner and I really dont know much.
The system is due but this part is the only thing holding me back.

If you may please help me with the code that I should add that will allow
the connection pooling. If you could help I would be the happiest person ever.

I am not good with java so if I can work with JSP its best.
 
Gurjit Sandhu
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have send server.xml and web.xml along with source code. please also tell what problem you are facing means the output error log you are getting with the application.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned, following the server's documentation is straight forward. And you do not want to be doing this from your jsp. The jsp is your presentation layer and should not have any code. If you are not good with Java, then you will likely run into trouble if you put all that code in your jsp.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic