aspose file tools*
The moose likes JDBC and the fly likes using datasource - connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "using datasource - connection pooling" Watch "using datasource - connection pooling" New topic
Author

using datasource - connection pooling

riicha singh
Greenhorn

Joined: Jan 21, 2006
Posts: 2
Hi,

I am using websphere application developer for my j2ee application (jsp, servlets). I have to do connection pooling for my application.
for this I have configured a datasource object in websphere.

I am using javax.sql.DataSource object to get the connection

Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/ds1");
Connection con = ds.getConnection(userid, pwd);

I want to know that whether using a javax.sql.DataSource object as above will provide connection pooling.
Or do I have to used objects of javax.sql.PooledConnection or javax.sql.ConnectionPoolDataSource classes.

Thanks,
Richa
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30972
    
159

Richa,
Welcome to JavaRanch!

The code itself is the same whether you use connection pooling or not. When you set up the ds1 datasource, it uses a certain class from the driver. That class determines whether connection pooling is used. For example, db2 provides a non-connection pool datasource, a connection pool datasource and an XA (transactional) datasource in the driver zip file.


[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
riicha singh
Greenhorn

Joined: Jan 21, 2006
Posts: 2
Hi Jeanne,

I am using microsoft sql server driver 2000.


-
Richa
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Each JDBC data source has a pool of JDBC connections that is created when the data source is deployed or at server startup. For this to work, you must first configure a connection pool in WAS and then associate your DataSource with the pool.

The code you have posted will obtain the connection wrapper object from the pool.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
wood burning stoves
 
subject: using datasource - connection pooling