Sample demonstrating the usage of LONGRAW type


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 application show how to perform inserts and retrieval from a LONGRAW column using JDBC. The sample uses the JDBC-Thin driver; the code is the same for JDBC-OCI, except for the database URL syntax.

Table Creation: This application requires a table AIRLINES_LONGRAW_TABLE to be  present.


Steps in the Application


 1) The user invokes the application, and the application displays the connection status and any errors in the status bar.

 2) If the connection was successful, the sample populates the JTable with CODE. NAME and PARTNER values for all rows in AIRLINES_LONGRAW_TABLE.

 3) When the user chooses an airline from the JTable,the AIRLINE_LOGO which is a LONGRAW column is retrieved and the GIF data in the column is displayed.

 4) When the user presses Exit, 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 (can be downloaded from here )
  • Oracle9i (Database) or higher running SQL*Net TCP/IP listener. 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

Run the sample using Oracle9i JDeveloper

Run the sample using the JDK environment


Install the sample

 Step 1. Unjar  LongRawSample.jar using Winzip, or using the following command:
              > jar xvf LongRawSample.jar . This creates a directory LongRawSample.

 Step 2. Edit Connection.properties file. 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

Run the sample using Oracle9i JDeveloper

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

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

 Step 3. Right click on  the file PopulateTable.java, and select Run. This will create a table AIRLINES_LONGRAW_TABLE and populate it with  binary data from the GIF files present under LongRawSample

 Step 4. Select Run/Run LongRawSample.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. Make sure that connection.properties,the GIF image files and LongRawSample/src are in the CLASSPATH.

 Step 2.  Change directory to LongRawSample/src/oracle/otnsamples/jdbc/longraw. Compile the files using javac:

               %javac *.java

 Step 3.
Run the class file using java. This will create the required database tables:            
            
              %java oracle.otnsamples.jdbc.longraw.PopulateTable

 Step 4. Run the class file using java:

               %java oracle.otnsamples.jdbc.longraw.LongRawSample

Description of Sample Files

The directory structure of the deliverable LongRawSample.jar will be as shown below

LongRawSample is the top level directory.

Directory
Files
Description
LongRawSample Readme.html This file
LongRawSample.jws The Oracle9i JDeveloper workspace file
LongRawSample.jpr The Oracle9i JDeveloper project file
Connection.properties This file has the details of the database connection parameters
GIF files Binary files which are loaded in the table
LongRawSample\src\oracle\otnsamples\jdbc\longraw\ LongRawSample.java The source file for sample
LongRawFrame.java The source file for the sample User Interface
PopulateTable.java The source for the class which creates the  table and populates it .
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.