1.编写一个java程序.
public class OracleJavaProc
{
public static void main(String[] argv)
{
System.out.println("It's a Java Oracle procedure.");
}
}
2.使用javac生成class
javac OracleJavaProc
3.在数据库中引用
create or replace java class using bfile(java_dir,'test.class');
create or replace procedure test_j as language java name 'OracleJavaProc.main(java.lang.String[])';
注意:
需建立一个directory目录
create or replace directory java_dir as '/home/oracle/java' ;
4.输出结果:
SQL>call dbms_java.set_output(5000);
SQL>exec test_j ;
It a Java Oracle procedure.
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02