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
This is the main layout of the administration console of IBM WAS
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
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
When you are done click on Apply, Okay and Save it The sample output should be like this:
If we succeeded on file path definition now navigate to Security > Global Security > Java Authentication and Authorization Service > J2C Authentication Data
Here we have no options click on New
In this screen we will be defining our data sources username and password. Please make sure your Credentials are IDENTICALLY THE SAME
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:
Now navigate to Resources > JDBC > JDBC Providers
Here you see nothing is defined, Click on new
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
In this screen oracle jar file path definition is required, since we have already defined, skip this part
When we finish the output screen should be
Now In the same screen click to Data Sources
As you see nothing is defined click on New button to define one
Data source name: Oracle JDBC Driver
JNDI Name: jdbc/OracleDS
Once completed click on next
Here select the existed JDBC provider
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
Here we will choose what we defined in JDBC Providers page
once completed click on next. The sample output looks like below
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