This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Websphere and the fly likes CONNECTION POOL in WAS 3.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "CONNECTION POOL in WAS 3.5" Watch "CONNECTION POOL in WAS 3.5" New topic


mou haj
Ranch Hand

Joined: Sep 12, 2001
Posts: 81
Can any body tell me how to create connection pools in WAS 3.5 and use them in EJB, JSP etc
Thanx :-)
Peter Garduno

Joined: Feb 15, 2002
Posts: 2
Weel, I hope this helps you
To create a datasource on demand in an application, the application must do the following:

1. Create a Properties object with datasource properties.

2. Obtain a datasource from the factory.

3. Bind the datasource into JNDI.


try {

//Create a properties file for the DataSource java.util.Properties prop = new java.util.Properties();



prop.put(DataSourceFactory.DESCRIPTION,"My sample

prop.put("databaseName", "sample");

//Obtain a DataSource from the factory
DataSource ds = DataSourceFactory.getDataSource(prop);

//Bind the DataSource into JNDI

} catch (ClassNotFoundException cnfe){

//check the class path for all necessary classes

} catch (CMFactoryException cmfe){

//Example of exception: incorrect


} catch (NamingException ne) {

//Example of exception:

//datasource by this name may already exist


I am working with WebSphere 4.0 and I am also using the pool, we could stay in contact to help each other.
ravindran shanmugam

Joined: Aug 30, 2001
Posts: 15
How do we actually get the database connection after that ?

I'm using the following class for getting connection ,

class DBConnect {
static DataSource ds = null;
static {
try {
Hashtable parms = new Hashtable();
Context ctx = new InitialContext(parms);
ds = (DataSource) ctx.lookup("jdbc/jndi");
}catch(Exception e) {
public Connection getDBConnection(){
Connection conn = null;
try {
conn = ds.getConnection("USER","PASSWD");
}catch(Exception e) {
and calling getconnection whenever I need a connection. Will this not maintain a connection pool. In the help page Websphere states that getting connection thorugh DataSource will automatically maintain a connection Pool.
please include me in your loop
I agree. Here's the link:
subject: CONNECTION POOL in WAS 3.5
It's not a secret anymore!