• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Postgres on WSAD 5.1 - it works

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for sharing this Todd!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, thanks a lot.
admire your efforts and wisdom.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Boss this help me to configure create datasource in Rad8.5........
again thanks a lot.....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic