Oracle8i SQLJ Developer's Guide and Reference Release 3 (8.1.7) Part Number A83723-01 |
|
Although this manual mainly discusses writing for client-side SQLJ applications, you may find it useful to run SQLJ code in the following scenarios:
Because the SQLJ runtime is pure Java, you can use SQLJ source code in applets as well as applications. There are, however, a few considerations, as discussed below.
For an example, see "Applet Sample".
For applet issues that apply more generally to the Oracle JDBC drivers, see the Oracle8i JDBC Developer's Guide and Reference, which includes discussion of firewalls and security issues as well.
The following general considerations apply to the use of Oracle SQLJ applets.
sqlj.runtime sqlj.runtime.ref sqlj.runtime.profile sqlj.runtime.profile.ref sqlj.runtime.error
as well as the following if you used Oracle customization:
oracle.sqlj.runtime oracle.sqlj.runtime.error
These classes are included with your Oracle installation in the file:
[Oracle Home]/lib/runtime11.zip
When end users run your SQLJ applet, classes in their CLASSPATH
may conflict with classes that are downloaded with the applet.
Oracle, therefore, recommends that end users clear their CLASSPATH
before running the applet.
Here are some additional considerations regarding the Java environment and use of Oracle-specific features.
One option is to use a Java plug-in offered by Sun Microsystems. For information, refer to the following Web site:
http://www.javasoft.com/products/plugin
.ser
extension, which is the extension employed by the SQLJ serialized object files that are used for profiles. The Sun Microsystems Java plug-in, however, supports .ser
files.
Alternatively, if you do not want to use the plug-in, Oracle SQLJ offers the -ser2class
option to convert .ser
files to .class
files during translation. See "Conversion of .ser File to .class File (-ser2class)" for more information.
oracle.sqlj.*
. The Oracle SQLJ runtime library in the runtime.zip
file always requires the Java Reflection API (java.lang.reflect.*
); the runtime libraries in runtime11.zip
, runtime12.zip
, and runtime12ee.zip
must use the Reflection API only in the circumstances outlined below. Most browsers do not support the Reflection API or impose security restrictions, but Sun's Java plug-in provides support for the Reflection API.
Note:
The term "Oracle-specific features" refers both to the use of Oracle type extensions (discussed in Chapter 5, "Type Support") and the use of SQLJ features that require your application to be customized to work against an Oracle database (for example, this is true of the |
java.lang.reflect.*
), regardless of the version of the SQLJ runtime you are using:
CAST
statement
java.sql.Ref/Struct/Blob/Clob
objects
oracle.sql.CustomDatum
or java.sql.SQLData
interfaces
runtime11.zip
library for your applets. Doing so permits you to use Oracle-specific features and Oracle-specific customization.
-profile=false
when you translate the code. (See "Profile Customization Flag (-profile)".) You can obtain a generic SQLJ runtime by removing all classes under oracle.sqlj.*
from the runtime.zip
library. If you neglect to set -profile=false
, then the default Oracle customizer will load Oracle-specific runtime classes. This will result in your applet requiring the Oracle runtime even though it does not use Oracle-specific features.
The preceding issues can be summarized as follows, focusing on users with Internet Explorer and Netscape browsers:
runtime11.zip
and classes111.zip
libraries. In this case, the SQLJ and JDBC versions must match. For example, to use the SQLJ 8.1.7 runtime, you must have the Oracle 8.1.7 JDBC driver.
CAST
statement in your SQLJ statements, then either the browser in which you run must support JDK 1.1 and permit reflection, or you must run your applet through a browser Java plug-in.
-profile=false
) and distribute it with the generic SQLJ runtime subset.
For an example of a generic SQLJ applet (not using Oracle-specific features), see "Applet Sample".
Note:
In addition to its use in client applications, SQLJ code can run within the target Oracle8i server in stored procedures, stored functions, triggers, Enterprise JavaBeans, or CORBA objects. Server-side access occurs through an Oracle JDBC driver that runs inside the server itself. Additionally, the Oracle8i server has an embedded SQLJ translator so that SQLJ source files for server-side use can optionally be translated directly in the server.
The two main areas to consider, which Chapter 11, "SQLJ in the Server", discusses in detail are:
Coding a SQLJ application for use within the target Oracle8i server is similar to coding for client-side use. What issues do exist are due to general JDBC characteristics, as opposed to SQLJ-specific characteristics. The main differences involve connections:
Additionally, the JDBC server-side driver used for connections within the server does not support auto-commit mode.
Note: There is also a server-side Thin driver for connecting to one server from code that runs in another. This case is effectively the same as using a Thin driver from a client and is coded in the same way. See "Overview of the Oracle JDBC Drivers". |
You can translate and compile your code either on a client or in the server. If you do this on a client, you can then load the class and resource files into the server from your client machine, either pushing them from the client using the Oracle loadjava
utility or pulling them in from the server using SQL commands. (It is convenient to have them all in a single .jar
file first.)
Alternatively, you can translate and load in one step, using the embedded server-side SQLJ translator. If you load a SQLJ source file instead of class or resource files, then translation and compilation are done automatically. In general, loadjava
or SQL commands can be used for class and resource files or for source files. From a user perspective .sqlj
files are treated the same as .java
files, with translation taking place implicitly.
See "Loading SQLJ Source and Translating in the Server" for information about using the embedded server-side translator.
You can use SQLJ on top of an Oracle Lite database. This section provides a brief overview of this functionality. For more information, refer to the Oracle Lite Java Developer's Guide.
Oracle Lite is a lightweight database that offers flexibility and versatility that larger databases cannot. It requires only 350K to 750K of memory for full functionality, natively synchronizes with the Palm Computing platform, and can run on Windows NT (3.51 or higher), Windows 95, and Windows 98. It offers an embedded environment that requires no background or server processes.
Oracle Lite is compatible with Oracle8i, previous versions of Oracle8, and Oracle7. It provides comprehensive support for Java, including JDBC, SQLJ, and Java stored procedures. There are two alternatives for access to the Oracle Lite database from Java programs:
This is intended for Java applications that use the relational data model, allowing them direct communication with the object-relational database engine.
Use the relational data model if your program has to access data that is already in SQL format, must run on top of other relational database systems, or uses very complex queries.
This is intended for Java applications that use either the Java object model or the Oracle Lite object model, allowing them to access persistent information stored in the Oracle Lite database, without having to map between the object model and the relational model. Use of JAC also requires a persistent Java proxy class to model the Oracle Lite schema. This can be generated by Oracle Lite tools.
Use the object model if you want your program to have a smaller footprint and run faster and you do not require the full capability of the SQL language.
There is interoperability between Oracle Lite JDBC and JAC, with JAC supporting all types that JDBC supports, and JDBC supporting JAC types that meet certain requirements.
Note the following requirements if you intend to run a Java program on top of an Oracle Lite database:
The JREs supplied with JDK 1.1.x and higher, Oracle JDeveloper, and Symantec Visual Cafe support JNI.
The JDBC driver implemented with Oracle Lite versions 3.6 and prior supports standard SQL92 types only, so Oracle-specific functionality cannot be used on top of these versions. Therefore, you cannot use Oracle type extensions, such as BFILE
and ROWID
, and user-defined object and collection types.
Beginning with version 4.0, however, Oracle Lite will include an Oracle-specific JDBC driver and Oracle-specific SQLJ runtime classes (including the Oracle semantics-checkers and customizer), allowing use of Oracle-specific features and type extensions.
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|