aspose file tools*
The moose likes JDBC 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
Bookmark "Questions Regarding Connection Pooling" Watch "Questions Regarding Connection Pooling" New topic
Author

Questions Regarding Connection Pooling

Shadab Khan
Greenhorn

Joined: Jul 11, 2002
Posts: 20
Hi
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?
Thanx
Abhay Kumar
Greenhorn

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(); "
C. SEARCH AND yOU WILL GET ANSWER FOR THIS
Renju Philip
Greenhorn

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
Thanks
renju
[ June 16, 2003: Message edited by: Renju Philip ]
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

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,
    Avi.
    [ June 17, 2003: Message edited by: Avi Abrami ]
     
    wood burning stoves
     
    subject: Questions Regarding Connection Pooling