wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes jdbc 2.0 connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jdbc 2.0 connection pooling" Watch "jdbc 2.0 connection pooling" New topic

jdbc 2.0 connection pooling

karim qazi

Joined: Mar 22, 2001
Posts: 20
I am using MS SQL Server 2000 and Tomcat 4.0.
I am using Microsoft's JDBC Driver for MS SQL Server 2000.
I have set up a data source in Tomcat and it works fine.
I was reading throught the documentation on the driver I am using and was wondering if I had to execute code like this to take advantage of connection pooling :
Context initialContext = new InitialContext();
Context envCtx = (Context) initialContext.lookup("java:comp/env");
ConnectionPoolDataSource pooledDataSource = (ConnectionPoolDataSource) envCtx.lookup("jdbc/SQLSERVER");
PooledConnection pcon = pooledDataSource.getPooledConnection();
Connection con = pcon.getConnection();
or if I could execute code like this :
Context initialContext = new InitialContext();
Context envCtx = (Context) initialContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) envCtx.lookup("jdbc/SQLSERVER");
Connection con = dataSource.getConnection();
Would the code above that doesnt use the ConnectionPoolDataSource interface still be taking advantage of ConnectionPooling?
Is this true or do you have to cast the jndi lookup of your data source to a ConnectionPoolDataSource to take advantage of connection pooling??
Do all jdbc compliant drivers take care of implementing the ConnectionPoolDataSource for you so all you have to do is define a datasource and it will pool the connections automatically??

[This message has been edited by karim qazi (edited November 20, 2001).]
I agree. Here's the link: http://aspose.com/file-tools
subject: jdbc 2.0 connection pooling
It's not a secret anymore!