jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Questions Regarding Connection Pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Questions Regarding Connection Pooling" Watch "Questions Regarding Connection Pooling" New topic

Questions Regarding Connection Pooling

Shadab Khan

Joined: Jul 11, 2002
Posts: 20
i have some confusion regarding how connection pooling is implemented..i have been doing some digging in to this lately but the more i read the more confused i get. i have some doubts here, will any of the posters here kindly clear them
a. Do i have to connect to my database via the DataSource method to take advantage of the connection pooling provided by my app server?..i have read conflicting information about this suggesting that Connection Pooling will not be provided to my app if i use DriverManager.getConnection()
b. if i chose to use the DataSource method do i have to implement the ConnectionPoolDataSource interface to provide the connection pooling for my app?
c. what is the best way to implement my own custom Connection pool?
Abhay Kumar

Joined: Jun 03, 2003
Posts: 15
A. is correct. If you use DriverManager.getConnection(), you are indeed bypassing the Connection Pool entirely.
B. usually, a third party connection pool will either give you the interface or they will give you the class file containing the DataSource object. In the latter case one has to Import the files, then create a new instance of it
"=new Source(); "
Renju Philip

Joined: Oct 28, 2002
Posts: 4
My answers
a.If you need to use Connetion Pool of the Application server you have to use DataSource.
b. I dint get the question but i will show a sample of how to use DataSource
InitialContext initialContext = new InitialContext();
DataSource dataSource = (DataSource)initialContext.lookup("java:comp/env/XXXX");
Connection connection = dataSource.getConnection();
c: Best way to implement Connection Pool . You could search on that. But i suggest you not to go for, if you use an application server that supports connection pooling. I beleive its an overhead. Its better we use what the application server provides
[ June 16, 2003: Message edited by: Renju Philip ]
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hey Shadab,
Are you going to reveal to us what the correct answers are? Or will that remain one of life's mysteries?
I'd like to throw in my two cents' worth (if you don't mind).
  • Well, that would depend on the implementation (or lack of) provided by your application server. What server would that be, by the way?
  • Not necessarily. Most probably not -- judging from the behaviour of the more popular application servers.
  • That would depend on what your requirements are. Sorry, but I didn't see any mention of your requirements, and I'm afraid I'm not a mind-reader.

  • Hope this has helped you.
    Good Luck,
    [ June 17, 2003: Message edited by: Avi Abrami ]
    I agree. Here's the link: http://aspose.com/file-tools
    subject: Questions Regarding Connection Pooling
    It's not a secret anymore!