Secure Thin JDBC Connection Sample

Table Of Contents

Introduction

Back To Top
This sample illustrates how to get a secure Thin JDBC connection and perform DML operations on the database using the secure connection.
This sample will list rows from the hotels table. The user can choose any of the Hotels by selecting it and perform either a Hotel booking or cancel a booking on that hotel.

JDBC Support for Data Encryption and Integrity

You can use Oracle Advanced Security data encryption and integrity features in your Java database applications, depending on related settings in the server.  When using an OCI driver in a thick-client setting, the parameters are set as in any Oracle client situation. When using the Thin driver, the parameters are set through a Java properties file.
Encryption is enabled or disabled based on a combination of the client-side encryption-level setting and the server-side encryption-level setting. Similarly, integrity is enabled or disabled based on a combination of the client-side integrity-level setting and the server-side integrity-level setting.

Encryption and integrity support the same setting levels-- REJECTED, ACCEPTED,REQUESTED, and REQUIRED. The table below shows how these possible settings on the client-side and server-side combine to either enable or disable the feature. 

Table  Client/Server Negotiations for Encryption or Integrity

  Client
Server   Rejected Accepted (default) Requested Required
Rejected OFF OFF OFF Connection fails
Accepted (default) OFF  OFF ON ON
Requested  OFF ON ON ON
Required fails ON ON ON

 

Dependencies

Back To Top
There is no additional software required to run this sample. 
 

Required Software

Back To Top
1. Calling Program : Oracle9i JDeveloper  or JDK 1.2 Environment or higher
2. Oracle9i 9.0.1 JDBC Thin Driver - You can download classes12.zip from and add it to your classpath
3. Travel Schema - This application requires a Oracle9i database, with the travel schema loaded. Travel Schema can be loaded, by importing the travel.dmp file that is available on the OTN website

 

Installation and Configuration

Back To Top
 Step 1. Unjar SecureThinDriver.jar using Winzip, or using the following command:
              > jar xvf SecureThinDriver.jar

         JDeveloper places jar.exe in JDEVELOPER_HOME\java\bin. Make  sure jar.exe is present in your system path.
         (JDEVELOPER_HOME  is the root directory of the JDeveloper installation).
 

Configuring Encryption Parameter Using Oracle Net Manager

To configure encryption on the client and on the server: 

   1.Start Oracle Net Manager: 
          On UNIX, run netmgr (for Oracle9i)  from $ORACLE_HOME/bin. 
          On Windows NT, choose Start > Programs > Oracle - HOME_NAME > Network Administration > Oracle Net Manager. 

   2.In the Navigator window, expand Local > Profile. 

   3.From the list in the right window pane, select Oracle Advanced Security; the Oracle Advanced Security tabbed window appears (see Figure below): 
 

  4.Choose the Encryption tab.  Select  SERVER from the pull-down list if not already selected.

  5. Select Encryption type as accepted (default value).

  6. In the Encryption Seed field, enter between 10 and 70 random characters.

  7.Choose File > Save Network Configuration; the sqlnet.ora file is updated. 

Run the Application using JDeveloper Environment

 Step 1. Using JDeveloper File/Open option select the SecureThinDriver.jws
         from the SecureThinDriver directory.

 Step 2. Edit the ConnectionParams.java file and substitute proper parameters to connect to
         your database (where Travel Schema is installed) .

 Step 3. Select Project/Make from JDeveloper main menu and select Make
         Project "SecureThinDriver.jpr" option

 Step 4. Click on "HotelReservationSample.java" file and Select Run/Run from
         JDeveloper main menu to run the application.
 

Run the Application from JDK Environment 

Step 1.  Set the required environment variables.

         1.1  Set JAVA_HOME to point to the directory of JDK installation
                set JAVA_HOME=c:\jdk1.2

         1.2  Set path to the following
                set PATH=%JAVA_HOME%\bin;%PATH%

         1.3  Include Oracle JDBC driver in the classpath.
                 e.g. set classpath=c:\Jdbc\classes12.zip;%CLASSPATH%

 
Step 2. Go to the directory <x>\SecureThinDriver\ where <x> is the directory in which
        the sample has been extracted.

Step 3. Edit the ConnectionParams.java file and substitute proper database parameters to 
        connect to your database (where Travel Schema is installed) .

Step 4. Compile the java program using javac:
         javac -d . *.java

         This creates a directory structure oracle\SecureThinDriver in SecureThinDriver with all the
         class files.

Step 5. Run the HotelReservationSample class file using java:
        java oracle.SecureThinDriver.HotelReservationSample
 
 

Description of Sample Files 

Back To Top
The sample is provided as a JAR file. This JAR file contains all the files required for the sample:
 
Name of File Description
HotelReservationSample.java  Source file for the main Sample Class
HotelReservationFrame.java Source file for the GUI.
SecureThinDriver.jws JDeveloper WorkSpace File
SecureThinDriver.jpr JDeveloper Project File
GridBagConstraints2.java Layout File
genTableModel.java  Support file
Readme.html This file specifies how to extract files from the jar file and prepare the sample for execution.
ConnectionParams.java Database parameters used for connecting the database.
ReservationDetails.java  Support file (Hotel Data Structures)
RoomType.java Support file (Hotel Data Structures)
HotelDetails.java Support file (Hotel Data Structures)


Revision history:  last revised on April 18, 2002

Please enter your comments about this sample in the OTN Sample code discussion forum.

E-mail this page
Printer View Printer View
Software. Hardware. Complete. About Oracle | Oracle and Sun| Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy