create or replace and compile java source named TestJava1 as public class TestJava1 { public static void test() { System.out.println("Hello"); } } |
执行它,以保存并编译。
2)增加一个procedure,执行如下命令:
代码
create or replace procedure testJava1 as language java name 'TestJava1.test()'; |
3)在command window里输入
代码
SET SERVEROUTPUT ON; CALL dbms_java.set_output(2000); |
以使System.out重定向到当前窗口;
在command window里输入,exec testJava1();
即可看到结果:
Hello
PL/SQL procedure successfully completed