 |
|
Oracle JSQL, JDBC and JAVA
Oracle Database Tips by Donald Burleson |
Oracle JSQL, JDBC and JAVA
In the previous examples, we didn't deal with JAVA
against persistent objects. To use JAVA against persistent objects
in Oracle8 you will have to use the JDBC or JSQL protocols.
JDBC
The JDBC protocol sets up a predefined set of
classes that allow access to SQL databases. The proper classes must
be invoked against the proper database (be it SQLAccess or Oracle,
or whatever.)
JSQL
The JSQL protocol is actually a pre-interpreter for
JAVA scripts which adhere to the JSQL coding standards. A properly
coded JAVA applet (an applet is a standalone section of JAVA code
that is treated as an object) or script is fed into the JSQL
pre-interpreter which converts all embedded SQL calls into something
standard JAVA interpreters can understand. The pre-interpreted JSQL
code is then used identically to standard JAVA applets or scripts.
Notice that the oci8 client connection is used in
Listing 13.9, other possible values include oci7, and thin. The only
valid driver for access of remote databases is thin. The difference
between the thin type of driver and the oci7 or oci8 driver is that
the thin driver is internally implemented while the others depend on
externally defined DLL (Dynamic Link Libraries). This dependence on
external files in the oci7 and oci8 drivers results in a security
violation for remote database access attempts through JDBC if they
are used for that purpose. The thin client is usually used in
applets.
To access PL/SQL from within JAVA either the entire
PL/SQL script is passed as a single argument, or, an execute call is
made against a pre-built PL/SQL stored procedure or function.
Obviously the latter is the option of choice because it will reduce
the number of network round-trips required to perform the same
function improving performance. The appletviewer, included with the
JDK download, is used to test and execute applets. An example HTML
wrapper used for testing applets is shown in Listing 8.
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Author"
CONTENT="">
<META NAME="GENERATOR"
CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
</HEAD>
<BODY>
<APPLET
CODE=DisplayImage2.class WIDTH=600 HEIGHT=560>
</APPLET>
</BODY>
</HTML>
|