Getting control of the Oracle JavaVirtual Machine

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++) 
 System.out.println(args[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 
'dbatest.main(java.lang.String[])'; 
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');
DBA
Test
Call completed.

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

Previous   Next

Prev  [1] [2] [3] [4] [5] [6] [7] Next

Close    To Top
  • Prev Article-Database:
  • Next Article-Database:
  • Now: Tutorial for Web and Software Design > Database > Oracle > Database Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction