wood burning stoves*
The moose likes Websphere and the fly likes Postgres on WSAD 5.1 - it works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Postgres on WSAD 5.1 - it works" Watch "Postgres on WSAD 5.1 - it works" New topic
Author

Postgres on WSAD 5.1 - it works

Todd Johnson
Ranch Hand

Joined: Sep 03, 2005
Posts: 61
I spent all day trying to find out how to set up a v5 datasource for PostgreSQL in Websphere Application Developer. I found a lot of other people who were also trying but had not been successful. I was able to get it working so I figured I'd post a how-to for to save the next guy some grief.

Out on the net, and even in the Postgres mailing lists, there seems to be a consensus that it wouldn't be possible until Postgres implement two phase commits and they implemented an XADataSource in the jdbc driver. That is being worked on, and it sounds like it will come out in the next version. But I wanted to get something running now.

For the record I'm using PostgreSQL 8.1-beta3. It should work on any 8.x version as long as you have the latest JDBC drivers. The earlier drivers don't have a class that implements javax.sql.ConnectionPoolDataSource. This is what you need to avoid having XADataSource support. Currently I'm using the 8.1 JDBC drivers.

This example assumes that I have a postgres database running on the local machine on it's normal port#5432. There is a user defined within postgres as "wsuser" with the password "wspass". There is a database named "wsdatabase" setup that "wsuser" has access to.

1) Add a JAAS Authentication Entry.
For a v5 datasource the first thing we need to configure is the username and password. Open the server configuration screen and click on the security tab. Under the "JAAS Authentication Entries": section click the "Add.." button. Enter the following for the fields...


2)Configure the JDBC driver.
Click the "Data source" tab at the bottom of the server configuration screen. Click the "Add..." button under the "JDBC provider list:" section. For "Database type" click "User-defined". For "JDBC provider type" click "User-defined JDBC Provider". Now click "NEXT". Enter the following for the fields on the next screen:

Click "FINISH".
*(some path) refers to the directory containing your PostgreSQL jdbc drivers. This is usually where you installed PostgreSQL in a subdirectory named "jdbc".

3)Configure the data source.
Click "Add.." under the "Data source defined in the JDBC provider selected above:" section. Choose "Version 5.0 data source" and click "NEXT". Fill out the fields on the next screen as follows:

Click "FINISH".

4) Configure the resource properties.
Under the "Resource properties defined in the data source selected above:" section add the following entries.


5) Add a resource reference to your web project's deployment descriptor.
For the web project you plan to run on the server, bring up web.xml. Click on the "References" tab at the bottom. Click on the "Resource" tab at the top. Click "Add" under the "The following resource references are used in this web application" section. Click on the new "(New ResourseRef)" entry and type "jdbc/ds1". Fill out the "Details" section as follows:


Fill out the "Websphere Bindings" section as follows



You should be done! If anyone catches any mistypes or mistakes I made while typing this up, please correct me. Thanks!


*Editted a few times to make it easier to read...
[ October 19, 2005: Message edited by: Todd Johnson ]

[ October 19, 2005: Message edited by: Todd Johnson ]

[ October 19, 2005: Message edited by: Todd Johnson ]
[ October 19, 2005: Message edited by: Todd Johnson ]
Todd Johnson
Ranch Hand

Joined: Sep 03, 2005
Posts: 61
Here is some ugly looking servlet code to test the connection... The webpage was interpretting the HTML inside the println() statements so I replaced the "<>" with "[]".


[ October 19, 2005: Message edited by: Todd Johnson ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Thanks for sharing this Todd!


[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
Frank Tao
Greenhorn

Joined: Oct 23, 2005
Posts: 1
Oh, thanks a lot.
admire your efforts and wisdom.
Tara Shankar
Greenhorn

Joined: Dec 28, 2012
Posts: 1
Thank you Boss this help me to configure create datasource in Rad8.5........
again thanks a lot.....
 
 
subject: Postgres on WSAD 5.1 - it works
 
Similar Threads
JDBC drivers
Tutorial PostgreSQL 8.3 on Glassfish V2.1 for ConnectionPool in Netbeans 6.5.1, WindowsXP (Post 3)
jdbc
WAS 5 - Error while connecting to Oracle datasource:
Unable to connect to Data Source