oracle中编写java代码

时间:2022-04-19 19:19:10
  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;

oracle中编写java代码

创建存储过程

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