STEP 1: INSTALL ORACLE
The first step is to install the Oracle drivers and the tnsnames.ora file into our system. To do this, install the Oracle client onto the machine that contains WSAD by following the instructions provided by Oracle. For simplicity's sake, this article assumes use of the defaults provided by the Oracle installation wizard.STEP 2: SET UP THE DEFAULT USER PASSWORD
This is part of the new J2C security configuration and it is located on the Security tab. In this section, we will create a user ID and password and assign it to an alias ID. This alias is required in Step 5.
WSAD uses an embedded server to test development code. To use this server we must first create a new server and configuration. Create a new server by selecting New -> Other -> Server/Configuration from the menu.On the first screen enter Test Server as the server name and select Test Environment as the server type. Use the default port of 9080 and click on the Finish button. This will create a new server and configuration in the Server Configuration screen located in the lower panel of WSAD.STEP 4: ADD THE JDBC DRIVER
This step will link the Oracle driver we installed in Step 1 to the newly created server/configuration.
The data source is where we assign the JNDI name and alias users.
The only required field in the Resources screen is the URL. This field is used by the server to look up the tnsnames.ora file and find the port to the database. Select the URL and make the following modification.The URL format is jdbc:oracle:thin: @xxx.xxx.xxx.xxx:1521:dbalias. This URL is broken into four sections delimited by colons. The URL is defined as follows:
This URL needs to match the Oracle configuration for your installation. It is essential that these fields match the corresponding tnsnames.ora file. If any of the information is incorrect, you'll receive errors.
//JNDI connection code
InitialContext context = new InitialContext();
DataSource dcDS = (DataSource) context.lookup("jdbc/ds3");
conn = dcDS.getConnection();