java存儲資料庫
『壹』 濡備綍鍦∣racle鏁版嵁搴撲腑浣跨敤java瀛樺偍榪囩▼
銆銆鏈鏂囦互Oracle涓轟緥 浠嬬粛涓涓媕ava瀛樺偍榪囩▼鐨勫叿浣撶敤娉
銆銆
銆銆
銆銆 涓 濡備綍鍒涘緩java瀛樺偍榪囩▼錛
銆銆閫氬父鏈変笁縐嶆柟娉曟潵鍒涘緩java瀛樺偍榪囩▼
銆銆
銆銆 浣跨敤Oracle鐨剆ql璇鍙ユ潵鍒涘緩
銆銆
銆銆e g 浣跨敤create or replace and pile java source named as
銆銆鍚庤竟璺熶笂java婧愮▼搴 瑕佹眰綾葷殑鏂規硶蹇呴』鏄痯ublic static鐨 鎵嶈兘鐢ㄤ簬瀛樺偍榪囩▼
銆銆
銆銆sql> create or replace and pile java source named javademo
銆銆 as
銆銆 import java sql *;
銆銆 public class JavaDemo
銆銆 {
銆銆 public static void main(String[] argv)
銆銆 {
銆銆 System out println( hello java demo );
銆銆 }
銆銆 }
銆銆 /
銆銆
銆銆Java 宸插壋寤
銆銆
銆銆SQL> show errors java source javademo
銆銆娌℃湁閿欒
銆銆
銆銆SQL> create or replace procere javademo
銆銆 as
銆銆 language java name JavaDemo main(java lang String[]) ;
銆銆 /
銆銆
銆銆榪囩▼宸插壋寤
銆銆
銆銆SQL> set serveroutput on
銆銆SQL> call javademo ();
銆銆
銆銆璋冪敤瀹屾垚
銆銆
銆銆SQL> call dbms_java set_output( );
銆銆
銆銆璋冪敤瀹屾垚
銆銆
銆銆SQL> call javademo ();
銆銆hello java demo
銆銆
銆銆璋冪敤瀹屾垚
銆銆
銆銆SQL> call javademo ();
銆銆hello java demo
銆銆璋冪敤瀹屾垚
銆銆 浣跨敤澶栭儴class鏂囦歡鏉ヨ呰澆鍒涘緩
銆銆e g 榪欓噷鏃㈢劧鐢ㄥ埌浜嗗栭儴鏂囦歡 蹇呯劧瑕佸皢class鏂囦歡鏀懼埌oracle Server鐨勬煇涓鐩褰曚笅杈
銆銆
銆銆public class OracleJavaProc
銆銆{
銆銆public static void main(String[] argv)
銆銆{
銆銆System out println( It s a Java Oracle procere );
銆銆}
銆銆}
銆銆
銆銆
銆銆SQL> grant create any directory to scott;
銆銆
銆銆鎺堟潈鎴愬姛
銆銆
銆銆SQL> conn scott/tiger@iihero oracledb
銆銆宸茶繛鎺
銆銆SQL> create or replace directory test_dir as d:oracle ;
銆銆
銆銆鐩褰曞凡鍒涘緩
銆銆
銆銆SQL> create or replace java class using bfile(test_dir OracleJavaProc CLASS )
銆銆 /
銆銆
銆銆Java 宸插壋寤
銆銆
銆銆SQL> create or replace procere testjavaproc as language java name OracleJavaProc main(java lang String[]) ;
銆銆 /
銆銆
銆銆榪囩▼宸插壋寤
銆銆
銆銆SQL> call testjavaproc();
銆銆
銆銆璋冪敤瀹屾垚
銆銆
銆銆SQL> execute testjavaproc;
銆銆
銆銆PL/SQL 榪囩▼宸叉垚鍔熷畬鎴
銆銆
銆銆SQL> set serveroutput on size
銆銆SQL> call dbms_java set_output( );
銆銆
銆銆璋冪敤瀹屾垚
銆銆
銆銆SQL> execute testjavaproc;
lishixin/Article/program/Oracle/201311/17720