• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to do Connection Pooling

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am working on a project and i got the complete implementaion to do. I thought to make Connection pooling for JDBC but don't have any idea how to do it (using TomCat) ... can any one of you help me or point me to some nice and detail tutorial, (i don't have much time to search on google and to look for the best tutorial). please help me out.

Regards,
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Connection pooling implementation varies from container to container.

Since you've told us you're using Tomcat, I'll move this thread to the Tomcat forum for you.
[ August 15, 2006: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two general ways to go about it.

1.) Add a connection pool directly to your app.
See:
http://jakarta.apache.org/commons/dbcp

or

2.) Use container managed connection pooling.
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

Unless you have a real good reason to go with the first, I would recomend starting with the second.
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, i have an application to be build by 1 week. I am managing the total design architect as well. To handle Database i thought to do Connection Pooling.

I want to ask, should i do for connection pooling or should i make a STATIC DBConnection class, which loads at Server startup and make a connection?
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more question, can you suggest me when to choose PreparedStatement and when to use Statement?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Muhammad Ali Amin:
thanks, i have an application to be build by 1 week. I am managing the total design architect as well. To handle Database i thought to do Connection Pooling.

I want to ask, should i do for connection pooling or should i make a STATIC DBConnection class, which loads at Server startup and make a connection?



Your approach will vary according to which of the two options (listed above) you choose. If you're pressed for time, I think the container managed pooling would be the simpler and faster of the two. See the link given for example code.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Muhammad Ali Amin:
One more question, can you suggest me when to choose PreparedStatement and when to use Statement?



We have a forum dedicated to JDBC.
Start a new topic in that forum with this question.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic