Starting with Oracle8i Database, the Oracle Database Server has included a Java Virtual Machine that allows Java programs to run efficiently in the server memory space. Many of the core Java class libraries are bundled with Oracle as well, resulting not only in a formidable weapon in the programmer’s arsenal, but also a formidable topic for a PL/SQL book! That’s why the objectives for this chapter are limited to the following:
Providing the information you need to load Java classes into the Oracle database, manage those new database objects, and publish them for use inside PL/SQL.
Offering a basic tutorial on building Java classes that will provide enough guidance to let you construct simple classes to access underlying Java functionality.
In preview, here is the usual way you will create and expose Java stored procedures:
Write the Java source code. You can use any convenient text editor or IDE such as Oracle’s JDeveloper.
Compile your Java into classes and, optionally, bundle them into .jar files. Again, you can use an IDE or Sun’s command-line javac compiler. (Strictly speaking, this step is optional because you can load the source into Oracle and use the built-in Java compiler.)
Load the Java classes into Oracle using the loadjava command-line utility or the CREATE JAVA statement.
Publish the Java class methods by writing PL/SQL “wrappers” to invoke the Java code.
Grant privileges as required on the PL/SQL wrapper.
Call the PL/SQL programs from any one of a number of ...