O'Reilly logo

Oracle PL/SQL Programming, 5th Edition by Bill Pribyl, Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Oracle and Java

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:

  1. Write the Java source code. You can use any convenient text editor or IDE such as Oracle’s JDeveloper.

  2. 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.)

  3. Load the Java classes into Oracle using the loadjava command-line utility or the CREATE JAVA statement.

  4. Publish the Java class methods by writing PL/SQL “wrappers” to invoke the Java code.

  5. Grant privileges as required on the PL/SQL wrapper.

  6. Call the PL/SQL programs from any one of a number of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required