Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle SQLJ loadjava Utility

Oracle Tips by Burleson Consulting
Don Burleson

 


The SQLJ loadjava Utility

The loadjava utility (in Oracle 8.1.5 and up) loads Java source and class files into the database. When class files are created in a conventional manner, outside the database, loadjava is used to get them into the database.

loadjava requires two database privileges to load java objects into your own schema: CREATE PROCEDURE and CREATE TABLE. To load Java objects into a schema other than the currently connected user, CREATE ANY PROCEDURE and CREATE ANY TABLE Oracle privileges are required for the loadjava user.

This example will use a simple Java program that will be compiled outside of Oracle and then loaded into the database.

see loadjava script download 

The class file is now loaded into the database and visible from the dba_objects view with an object type of JAVA CLASS.

From SQL*Plus, create the PL/SQL wrapper to invoke the newly loaded Java class:


SQL> create or replace procedure call_simplejava
2 as language java
3 name 'SimpleJava.showMessage()';
4 /

Execute the code from SQL*Plus:

SQL> set serveroutput on;
SQL> call dbms_java.set_output(50);

Call completed.

SQL> execute call_simplejava;
Here we are

PL/SQL procedure successfully completed.


In this example, the Java class file was loaded into the database. The Java source file can also be loaded. But, both the source and class files cannot be loaded at the same time.

C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.java

If loading many Java class files at one time, it is advisable to put them in a JAR file and load them into the database at one time, since the loadjava program will also load JAR files. loadjava provides many command line options for the Java developer. The complete list can be viewed by typing loadjava at the command line.

Just as loadjava loads the database with our Java files or classes, the dropjava utility deletes them. In the example below, the class file that was loaded with loadjava is removed. And just like loadjava, it will drop Java source, Java classes, or JAR files.

C:\oracle9i\bin>dropjava -u scott/tiger SimpleJava.class

Alternatively, instead of using the command line utility, you can call a package that will do the same thing:

SQL> call dbms_java.dropjava('... options...');

Dropjava can be used to delete Java objects from the database. These Java objects may have been loaded into the database through the loadjava utility. The next utility also loads code into the database; only instead of Java, it loads a PL/SQL Server Page (PSP).

loadjava script download 

The SQLJ Utility Loading and Dropping Java Objects

The loadjava utility (Oracle 8.1.5 and up) loads Java source and class files into the database. When class files are created in a conventional manner, outside the database, loadjava is used to get them into the database.

loadjava requires two database privileges to load java objects into your own schema: CREATE PROCEDURE and CREATE TABLE. To load Java objects into a schema other than the currently connected user, CREATE ANY PROCEDURE and CREATE ANY TABLE privileges are required.

This example will use a simple Java program that will be compiled outside of Oracle and then loaded into the database.

public class SimpleJava {

public void main(String[] args) {
System.out.println("Here we are");
}


From DOS or UNIX :

C:\oracle9i\bin>javac SimpleJava.java

C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.class


The class file is now loaded into the database and visible from the dba_objects view with an object type of JAVA CLASS.

From SQL*Plus, create the PL/SQL wrapper to invoke the newly loaded Java class:

SQL> create or replace procedure call_simplejava
2 as language java
3 name 'SimpleJava.showMessage()';
4 /


Execute the code from SQL*Plus:

SQL> set serveroutput on;
SQL> call dbms_java.set_output(50);

Call completed.

SQL> execute call_simplejava;
Here we are


PL/SQL procedure successfully completed.

In this example, the Java class file was loaded into the database. The Java source file can also be loaded. But, both the source and class files cannot be loaded at the same time.

C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.java

If loading many Java class files at one time, it is advisable to put them in a JAR file and load them into the database at one time, since the loadjava program will also load JAR files. A JAR file is a group of Java class files lumped into one file, a format similar to TAR (on UNIX ) and WinZip (on Windows). The contents of a JAR file can be viewed using these popular utilities. Java developers prefer to distribute a few JAR files rather than many individual Java class files.

loadjava provides many command line options for the Java developer. The complete list can be viewed by typing loadjava at the command line.

Just as loadjava loads the database with our Java files or classes, the dropjava utility deletes them. In the example below, the class file that was loaded with loadjava is removed. And just like loadjava, it will drop Java source, Java classes, or JAR files.

C:\oracle9i\bin>dropjava -u scott/tiger SimpleJava.class

Alternatively, instead of using the command line utility, you can call a package that will do the same thing:

SQL> call dbms_java.dropjava('... options...');

Dropjava can be used to delete Java objects from the database. These Java objects may have been loaded into the database through the loadjava utility. The next utility also loads code into the database; only instead of Java, it loads a PL/SQL Server Page (PSP).


 

 


For more details on Oracle utilities, see the book "Advanced Oracle Utilities" by Bert Scalzo, Donald K. Burleson, and Steve Callan.

You can buy it direct from the publisher for 30% off directly from Rampant TechPress.



 

 

��  
 
 
 
 

 
 
 

 
 
Oracle performance tuning software 
 
oracle dba poster
Oracle Linux poster
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.