Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

Oracle

Posted Apr 29, 2003

Getting Control of the Oracle Java Virtual Machine - Page 4

By Marin Komadina

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.



Oracle Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
Oracle Forum
Topic By Replies Updated
Oracle Data Mining: Classification jan.hasller 0 July 5th, 07:19 AM
Find duplicates - Unique IDs Lava 5 July 2nd, 08:30 AM
no matching unique or primary key rcanter 1 April 25th, 12:32 PM
Update values of one table based on condition of values in other table using Trigger Gladiator 3 February 29th, 06:01 PM