File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Connection Pool in WebSphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Connection Pool in WebSphere" Watch "Connection Pool in WebSphere" New topic

Connection Pool in WebSphere

Ranch Hand

Joined: Jun 03, 2001
Posts: 47
Hi all,
I have WSAD 5.1 and Oracle 8.1.7. Presently I am hardcoding the DB URL, username, password using JDBC thin driver. I want to prepare a connection pool for this Oracle connection in WSAD and use that connection pool name from my applications. How can I setup or create a connection pool in WSAD for Oracle database.
Thanks in advance.
maneesh subherwal
Ranch Hand

Joined: Aug 26, 2002
Posts: 42
This is a slightly lengthy description, so please bear with me...
1. Go to the 'Server Perspective' in WSAD.
2. If you have a server set up already, u will need to click on the server to set up the configuration.
3. Go to the Datasource Tab
4. Under 'JDBC Provider List', select the Add button.
5. Select Oracle and the Oracle Thin Driver.
6. Set the implementation class name to oracle.jdbc.pool.OracleConnectionPoolDataSource and specify a name (oracleDS) for this datasource.
7. Under DataSource, set a name (ORADS) and JNDI name (jdbc/ORADS). leave everything else as is.
8. Under Resource properties (with your ORADS Datasource selected), Add name as 'URL' and value as 'jdbc racle:thin:@serverName ort b'.
9. Save this and restart your server.
10. Use the following code to retrieve the datasource:

Hashtable parms = new Hashtable();
parms.put(Context.PROVIDER_URL, "iiop:///");
InitialContext ctx = new InitialContext(parms);
DataSource ds = (DataSource)ctx.lookup("jdbc/ORADS"); // if that is what you named it...

catch(NamingException e)

11. To Use the datasource,
ds.getConnection(userId, password);
I hope this helps...

Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
One point,
Please start using default InitialContext constructor. Now in version 5, there is local namespace for each server proces..
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
Hi again,
I tried that code, its good to know that it worked properly and I got connection. Thanks.
I have created a data source name as "DSN1", But I am getting some messages at server output, like:
Resource reference jdbc/DSN1 could not be located, so default values of the following are used: [Resource-ref settings]
res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]
isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)
[11/19/03 13:40:02:793 EST] 40000c3d ConnectionFac I J2CA0107I: Component-managed authentication alias not specified for connection factory or datasource DSN1.
[11/19/03 13:40:05:306 EST] 40000c3d WSRdbDataSour u Database version is
Oracle8i Enterprise Edition Release - 64bit Production
With the Partitioning option
JServer Release - 64bit Production
[11/19/03 13:40:05:306 EST] 40000c3d WSRdbDataSour u JDBC Driver version is
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Yes.. it will happen as you dont have a reference in your web deployment descriptor. You are trying to refer to this datasource from the Web project.. isnt it?
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
Yes, I am calling it from a Web Project (from JSP). What is the best way to change the code to avoid that warning message.
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Go to Web Deployment Descriptor, click on references tab, click on Resources tab
Click on Add button
(New ResourceRef) - replace this with the jndi name you gave in ur program. For example if you gave java:comp/env/jdbc/testds, type jdbc/typeds.
Type = javax.sql.DataSource (Make sure you havent selected javax.activation.DataSource:-)
Under Websphere Bindings
jndiname - name you gave while created your datasource.
Restart your server.
Good luck
I agree. Here's the link:
subject: Connection Pool in WebSphere
It's not a secret anymore!