JVM Operational Test

The DBA should check the JVM core functionality before developers and end users begin work. For a test we are going to create a Java class, compile it, load it in the database and execute it as a part of PL/SQL block.

Creating Java class:

# vi dbatest.java
public class EchoInput { 
public static void main (String[] args){ 
 for (int i=0; i<args.length;i++) 

Compile Java class file:

# javac dbatest.java
# ls 
-rw-r--r--   1 oracle   tivdba       132 Apr  2 15:54 dbatest.java
-rw-r--r--   1 oracle   tivdba       429 Apr  2 15:54 dbatest.class

Load Java class dbatest.class in the database:

#  loadjava -u artist/artist -v -r dbatest.class
initialization complete
loading  : dbatest
creating : dbatest
resolver :  
resolving: dbatest

The class is saved in user schema "Artist" and will be wrapped in the PL/SQL. In that way, we are providing a call for the Java stored procedure from the PL/SQL package:

SQL> create or replace procedure dba_test ( s1 varchar2, s2 varchar2 ) as language java name 
Procedure created.

As a final step, call to procedure:

SQL> set serveroutput on
SQL> call dbms_java.set_output(5000);
Call completed.
SQL> call dba_test('DBA', 'Test');
Call completed.

The basic JVM functionality is successfully checked and database is ready to use.