Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

jdbc 2.0 connection pooling

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic