aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Query 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 "Query regarding Connection pooling" Watch "Query regarding Connection pooling" New topic

Query regarding Connection pooling

Manish Sridharan
Ranch Hand

Joined: Jul 19, 2005
Posts: 64
Firstly, I have lot of Queries. so any one can answer any query will be helpful. I think java ranch is best forum to get answer related java queries. So I call upon all java geeks to clarify my doubts regarding this.

i m using mysql driver on tomcat webserver and using JNDI based connectionpooling.
and i made a connection succesfully.

i have made a connection accordingly as given in tomcat documentation on Connection pooling.

i have a number of querys

1. In the initial context , why we write string "java:/comp/env"
what its significance ? Does it point to particular location in the tomcat?

2. I have used org.apache.commons.dbcp.BasicDataSourceFactory . Does this class do the connection pooling? I think its just implementing data source interface. please explain.
i have used a commons-dbcp-1.2.1.jar .
and also i used mysql-connector-java-3.1.10-bin.jar for driver

3. there is MysqlConnectionPoolDataSource.class and MysqlDatasource.class in mysql-connector-java-3.1.10-bin.jar . Can I use this file for connection pooling and datasource connection . If yes then how shd i do it ? please explain.

4. I also want to make a class file for connection pooling instead of relying on tomcat to do the connection pooling for me. can i use these jar files for my own connection pooling? if yes then how should i do it ? please explain.

Manish S.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31781

Welcome to JavaRanch!

1. java:/comp/env states that you are using a reference. This is like a level of indirection. It's not a particular location though.

2. No. There is a SharedPoolDataSourceFactory that does connection pooling.

3. I'm not sure whether Mysql gives you connection pooling by default. (I think it doesn't though.) What does the documentation say?

4. It's usually best to let the server do connection pooling since it can do a good job. Second best is DBCP. You don't want to write your own though. It's complicated, hard to get right and it's already been done well.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Query regarding Connection pooling