DML Sample Application


This document is organized into following sub-sections :

  1. Overview of the Sample Application
  2. Required Software
  3. Installation and Configuration
  4. Description of Sample Files

Overview of the Sample Application

This sample application shows how to perform SQL INSERT, SELECT, UPDATE, and DELETE operations using JDBC. This sample uses the JDBC-Thin driver; the code is the same for JDBC-OCI, except for the database URL syntax.

Steps in the Sample

  1. The user invokes the application, and the application displays the connection status and errors, if any, in the status bar.
  2. If the user enters a new record in the text field and presses the INSERT button, the application inserts the corresponding record into the Airlines table.
  3. If the user enters the Airlines code in the code text field and presses the SELECT button, the record is displayed in the table area. If the user
    presses the SELECT button without entering an Airlines code in the code text field, the application displays all records in the database.
  4. If the user selects any record in the JTable, then the corresponding Airlines Code, Airlines Name, and Airlines Partner are displayed in the
    corresponding text fields. The user may then modify the record and press UPDATE to update or DELETE to delete the record.
  5. If the user presses the CLEAR Button, the application clears all text fields and the statusbar.
  6. If the user presses the EXIT Button, the application exits.

Required Software

  • Oracle9i JDeveloper or higher ( Note: JDeveloper is Oracle's Visual Java Development Tool and can be downloaded from here )
    or

    JDK1.2.x or above (can be downloaded from here )
  • Oracle9i (Database) or higher running SQL*Net TCP/IP listener. This can be downloaded from here.
  • Travel Schema needs to be loaded into the database. This can be downloaded from here.

Installation and Configuration

The section has instructions for step-by-step instructions to run this application successfully.
This will be discussed in the following subsections

Install the sample

Database setup

Run the sample using Oracle9i JDeveloper

Run the sample using the JDK environment

Install the sample

Step 1. Unjar DMLSample.jar using Winzip, or using the following command:

> jar xvf DMLSample.jar

You will find jar.exe in JDK_HOME\bin. Ensure that JDK_HOME\bin is present in your system path. (JDK_HOME is the root directory of the JDKx.x installation ).

This creates a folder DMLSample with all the source files

Step 2. Edit Connection.properties file located in the directory DMLSample\src. Change the hostname, portnumber and database name to those of the database instance you want to connect to.

Change the following lines:

HostName = insn104a.idc.oracle.com
SID = otn9i
Port = 1521
UserName = travel
Password = travel

Database Setup

The application requires the Travel Schema to be loaded into the database

Run the sample using Oracle9i JDeveloper

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

Step 2. Select Project/Make from JDeveloper main menu and select Make Project "DMLSample.jpr"

Step 3. Select Run/Run DMLSample.jpr from JDeveloper main menu to run the application.

Run the sample using the JDK Environment

 Step 1. Install Oracle JDBC Driver and include the zip/jar files in the CLASSPATH
              Ensure that DMLSample\src directory is also added to the CLASSPATH

 Step 2.  Change directory to DMLSample\src\oracle\otnsamples\jdbc\dml. Compile the files using javac:

               %javac *.java

 Step 3. Run the class file using java:            
            
              %java oracle.otnsamples.jdbc.dml.DMLSample

Description of Sample Files

Back To Top
The directory structure of the deliverable DMLSample.jar will be as shown below

DMLSample is the top level directory.

Directory
Files
Description
DMLSample Readme.html This file
DMLSample.jws The Oracle9i JDeveloper workspace file
DMLSample.jpr The Oracle9i JDeveloper project file
DMLSample\src Connection.properties This file has the details of the database connection parameters
DMLSample\src\oracle\otnsamples\jdbc\dml DMLSample.java The source file for sample
DMLFrame.java The source file for the sample User Interface
GenTableModel.java The source file for the GenTableModel class, which handles the JTable data

 



Please enter your comments about this sample in the OTN Sample Code Discussion Forum.