- 使用sql語句創建
create or replace and compile java source named test_java_source as
package test_java_source;
public class Test{
public void Test(){
}
//都是static的
public static String sayHello(){
return "Hello,World!";
}
}
public class Test2{
public static void main(String[] args){
System.out.println("Hello,World!");
}
}
在command命令中:
show errors java source test_java_source.Test2;
創建存儲過程
create or replace procedure test2 as
language java name 'test_java_source.Test2.main(java.lang.String[])';
創建函數:
create or replace function test_2 RETURN varchar2 is
language java name 'test_java_source.Test.sayHello() return String';
測試:
call dbms_java.set_output(5000);
call test2();
測試函數:
select test_2() from dual;
2、通過loadjava命令創建
可直接加載.class,.java,.jar文件
loadjava –help看幫助文檔
loadjava –u scott/tiger –v –r demo.java/demo.jar/demo.class
刪除jar文件時
dropjava –u scott/tiger –v –r demo.jar