aspose file tools*
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc 2.0 connection pooling" Watch "jdbc 2.0 connection pooling" New topic
Author

jdbc 2.0 connection pooling

karim qazi
Greenhorn

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??
Thanks.
Karim

[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