oracle中編寫java代碼


  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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM