Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to do Connection Pooling

 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • 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,
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic