|Oracle8i SQLJ Developer's Guide and Reference
Release 3 (8.1.7)
Part Number A83723-01
This section introduces the main SQLJ components and the concept of SQLJ profiles.
Oracle SQLJ consists of two major components:
The translator, written in pure Java, supports a programming syntax that allows you to embed SQL operations inside SQLJ executable statements. SQLJ executable statements, as well as SQLJ declarations, are preceded by the
#sql token and can be interspersed with Java statements in a SQLJ source code file. SQLJ source code file names must have the
The translator produces a
.java file and one or more SQLJ profiles, which contain information about your SQL operations. SQLJ then automatically invokes a Java compiler to produce
.class files from the
The SQLJ runtime, also written in pure Java, implements the desired actions of your SQL operations, accessing the database using a JDBC driver. The generic SQLJ standard does not require that a SQLJ runtime use a JDBC driver to access the database; however, the Oracle SQLJ runtime does require a JDBC driver, and, in fact, requires an Oracle JDBC driver if your application is customized with the default Oracle customizer (see below).
For more information about the runtime, see "SQLJ Runtime".
In addition to the translator and runtime, there is a component known as the customizer. A customizer tailors your SQLJ profiles for a particular database implementation and vendor-specific features and datatypes. By default, the Oracle SQLJ front end invokes an Oracle customizer to tailor your profiles for an Oracle database and Oracle-specific features and datatypes.
When you use the Oracle customizer during translation, your application will require the Oracle SQLJ runtime and an Oracle JDBC driver when it runs.
SQLJ profiles are serialized Java resources (or, optionally, classes) generated by the SQLJ translator, which contain details about the embedded SQL operations in your SQLJ source code. The translator creates these profiles, then either serializes them and puts them into binary resource files, or puts them into
.class files (according to your translator option settings).
SQLJ profiles are used in implementing the embedded SQL operations in your SQLJ executable statements. Profiles contain information about your SQL operations and the types and modes of data being accessed. A profile consists of a collection of entries, where each entry maps to one SQL operation. Each entry fully specifies the corresponding SQL operation, describing each of the parameters used in executing this instruction.
SQLJ generates a profile for each connection context class in your application, where, typically, each connection context class corresponds to a particular set of SQL entities you use in your database operations. (There is one default connection context class, and you can declare additional classes.) The SQLJ standard requires that the profiles be of standard format and content. Therefore, for your application to use vendor-specific extended features, your profiles must be customized. By default, this occurs automatically, with your profiles being customized to use Oracle-specific extended features.
Profile customization allows database vendors to add value in two ways:
PreparedStatementmethod calls in translated SQLJ code to
OraclePreparedStatementmethod calls, which provide support for Oracle type extensions.)
For example, you must customize your profile to use Oracle objects in your SQLJ application.
SQLJ-generated profile files feature binary portability. That is, you can port them as is and use them with other kinds of databases or in other environments if you have not employed vendor-specific database types or features. This is true of generated
.class files as well.