Defining a data source in IBM Websphere

Reading Time: 4 minutes

Hi

In this post I will be showing you how to define a datasource to databases. At work I needed to launch a project in my local server, and the project requires a database connection which has to be also defined in IBM WAS. The below everything you need is declared and explained. I will define an oracle data source.

First of all fire up the was server, I am running STS and it is defined in my server list. After the server is fired up, we need to launch to the Administration console

IBMWebsphere 1

This is the main layout of the administration console of IBM WAS

IBMWebsphere 2

First of all we need to set oracle jdbc driver path for WAS to use the jar.  Here you can download it. The jar is not available in maven repository, so that you will need to download it from Oracle’s web site. Please keep in mind we need to have ojdbc6 one not the ojdbc5.  Once you download it, we need to keep the file in a permanent location where “YOU WILL NOT DELETE” because as long as the data source is defined in server, you will have to keep it for WAS, I am assuming that you are keeping the jar in somewhere in C drive or in linux your home folder.

After downloading and locating the jar file move Navigate to Environment > WebSphere variables

Keep in mind you really need to know about the scope part. I am running my server in local so that in general the one selected in option box in my server is the right for local servers. Anyway here click on “ORACLE_JDBC_DRIVER_PATH” if it is not defined add a new one from the button

IBMWebsphere 3

Here the screen comes up, to the value textfield we only need to add the PATH of the jar file NOT PATH+FILENAME. As long as the jar file named as ojdbc6.jar WAS will automatically pick the file up. if your jar is in C:\libs just type it that way

IBMWebsphere 4

 

When you are done click on Apply, Okay and Save it The sample output should be like this:

IBMWebsphere 5

 

If we succeeded  on file path definition now navigate to Security > Global Security > Java Authentication and Authorization Service > J2C Authentication Data

IBMWebsphere 6

 

 

Here we have no options click on New

IBMWebsphere 7

 

In this screen we will be defining our data sources username and password. Please make sure your Credentials are IDENTICALLY THE SAME

IBMWebsphere 8

 

For Alias you can type anything you want, User ID is username and Password is the password of course. Description is optional, Alias could be named the way you wish When we are done the sample screen should be looking like this:

IBMWebsphere 9

 

Now navigate to Resources > JDBC > JDBC Providers

IBMWebsphere 10

 

Here you see nothing is defined, Click on new

IBMWebsphere 11

 

Here

Database Type: Oracle

Provider Type: Oracle JDBC Driver

Implementation Type: Connection Pool Data Source

Name: Oracle JDBC Driver

Description: Oracle JDBC Driver

Once completed click on next

IBMWebsphere 12

 

In this screen oracle jar file path definition is required, since we have already defined, skip this part

IBMWebsphere 13

 

When we finish the output screen should be

IBMWebsphere 14

 

Now In the same screen click to Data Sources

IBMWebsphere 15

 

As you see nothing is defined click on New button to define one

IBMWebsphere 16

 

Data source name: Oracle JDBC Driver

JNDI Name: jdbc/OracleDS

Once completed click on next

IBMWebsphere 17

 

Here select the existed JDBC provider

IBMWebsphere 18

 

Here we need to define the oracle full url it should be jdbc:oracle:thin:@//SERVERADDRESS/SCHEMA

Choose Oracle 11g data store helder and check the option click on Next

IBMWebsphere 19

 

Here we will choose what we defined in JDBC Providers page

once completed click on next. The sample output looks like below

IBMWebsphere 20

 

Once everything is done the next page we will test the connection. Check on the defined source and click on test. If all went successfully the server will return a successful message

IBMWebsphere 21