How do you setup an Oracle JDBC data source on WebSphere Application Server 7 using Admin Console?
Login to the Admin Console of the running server, i.e. Window -> Show Views -> Servers | right click the server -> Run Administration -> Run Administrative Console
Environment -> WebSphere variables
Find “ORACLE JDBC DRIVER PATH” Name out of the list (second page) and click its link
Set its “Value” to the “directory” (not the actual path + filename) where your ojdbc6.jar resides on your file system
We can set this path externally, either a stand alone ojdbc6.jar or find it with Oracle client packages, i.e. C:\app\\product\11.2.0\client_1
Click “Apply”, then “Save” (on top)
Back to WAS Admin Console, go to Security -> Global security
On “Authentication” panel, expand “Java Authentication and Authorization Service” -> J2C authentication data
Click “New”
Give it an Alias name, i.e. Alias_Oracle and input our current databases’ credential: User ID = your_db_username, Password = your_db_password
Click “Apply”, then “Save”
Go to Resources -> JDBC -> JDBC providers
Make sure that the right Scope has been selected, i.e. Node=DOMAINHOSTNAMENode01 or something
Click “New” to create a new JDBC provider
Step 1: Select “Oracle” from “Database type” menu | Provider type = Oracle JDBC Driver | Implementation type = Connection pool data source
Leave the “Name” as default, i.e. “Oracle JDBC Driver”
Step 2: if you have setup the ORACLE JDBC DRIVER PATH correctly, it should have the appropriate “Class path” to “ojdbc6.jar” already selected for you Step 3: Summary, click “Finish”
Go to Resources -> JDBC -> Data sources
Make sure the right Scope is selected , i.e. Node=DOMAINHOSTNAMENode01 or something
Click “New”
Step 1: Data source name = “Oracle JDBC Driver” | JNDI name = “jdbc/OracleDS”
Step 2: Select “Select an existing JDBC provider” = “Oracle JDBC Driver”
Step 3: URL = “jdbc:oracle:thin:@hostname:port:db_alias” | Data store helper class name = “Oracle11g data store helper”
Step 4: Component-managed authentication alias = DOMAINHOSTNAMENode01/Alias_Oracle
select “DefaultPrincipalMapping”
Step 5: Summary, click “Finish”
Back on “Data sources” screen, select the newly created data source and “Test connection”. If it succeeds, you are done
You can retrieve the data source programmatically:
Context initContext = new InitialContext(); dataSource = (DataSource)initContext.lookup("jdbc/OracleDS");