|Oracle8i SQLJ Developer's Guide and Reference
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, but the Oracle SQLJ runtime does require a JDBC driver, and in fact requires an Oracle JDBC driver if your application uses Oracle-specific features.
For more information about the runtime, see "SQLJ Runtime".
In addition to the translator and runtime, there is a component known as the customizer. SQLJ automatically invokes a customizer to tailor your SQLJ profiles for a particular database implementation and any vendor-specific features and datatypes. By default, SQLJ uses the Oracle customizer so that your application can use Oracle-specific features.
SQLJ profiles are serialized Java objects (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 type of database schema you connect to. (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 in order 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.