Setting Up Oracle JVM
With Oracle JVM, you can leverage Java programming within the Oracle database. When you are creating databases with Oracle Database Configuration Assistant (DBCA), Oracle JVM is an option. If you select the Oracle JVM option, the number of loaded Java schema objects in the database should be more than 8000 for Oracle Database 10g when you are querying as SYS using the following SQL command:
SELECT count (*)
FROM user_objects
WHERE object_type='JAVA CLASS';
Otherwise, you need to connect to the Oracle database as SYS user and run the $ORACLE_HOME/javavm/install/initjvm.sql and $ORACLE_HOME/rdbms/admin/catjava.sql scripts, as follows:
SQL>@javavm/install/initjvm.sql
SQL>@rdbms/admin/catjava.sql
Note | While Oracle XDK Java libraries can be loaded into the SYS user schema by running the $ORACLE_HOME/xdk/admin/initxml.sql in SYS, it is not recommended to do so because you may wish to reload the libraries to leverage new XDK features or bug fixes in a release on OTN. To simplify the maintenance of XDK Java libraries in Oracle JVM, you can create a new database user, for example XDK, and load the Java libraries into this user schema instead of SYS. |
To run initjvm.sql successfully, you also need reasonable sizes for SHARE_POOL_SIZE and JAVA_POOL_SIZE. The recommended sizes are as follows:
shared_pool_size = 50000000
java_pool_size = 20000000
After you install Oracle JVM, you can load, compile, and run Java programs in the Oracle database by creating Java stored procedures. In Chapter 27, we will discuss how you can leverage Java Stored Procedures to process XML using SAX from PL/SQL.