1. 使用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

 

posted on 2016-05-13 13:51  zyb_java  阅读(2676)  评论(0编辑  收藏  举报