[oracle@localhost ~]$ vi hellojava
public class hello
{
public static String world()
{
return "Hello world";
}
}
[oracle@localhost ~]$ javac hello.java
[oracle@localhost ~]$ loadjava -user scott/tiger hello.class
[oracle@localhost ~]$ sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 2月 23 09:53:51 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL>
SQL> create or replace function helloworld return varchar2 as language java name 'hello.world() return java.lang.String';
2 /
警告: 建立的函數含有編譯錯誤.
SQL> show error;
FUNCTION HELLOWORLD 發生錯誤:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/54 PLS-00311: "hello.world() ret return java.lang.String"
的宣告不完整或是格式不正確
SQL> exec Dbms_Java.Grant_Permission('SCOTT','java.io.FilePermission', '<>','read ,write, execute, delete');
exec Dbms_java.grant_permission('SCOTT', 'SYS:java.io.FilePermission', '<>','read ,write, execute, delete');
exec Dbms_Java.Grant_Permission('SCOTT', 'java.io.FilePermission', 'd:a.bat','read ,write, execute, delete');
exec dbms_java.grant_permission('SCOTT', 'java.lang.RuntimePermission','*','writeFileDescriptor' );
已順利完成 PL/SQL 程序.
SQL>
已順利完成 PL/SQL 程序.
SQL>
已順利完成 PL/SQL 程序.
SQL>
已順利完成 PL/SQL 程序.
SQL>
SQL>
SQL>
SQL>
CREATE OR REPLACE FUNCTION helloworld RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'hello.world () return java.lang.String';
2 /
警告: 建立的函數含有編譯錯誤.
SQL> shoe error;
SP2-0042: 不明的命令 "shoe error" - 已忽略此行的剩餘部份.
SQL> show error;
FUNCTION HELLOWORLD 發生錯誤:
LINE/COL ERROR
-------- -----------------------------------------------------------------
1/60 PLS-00103: 發現了符號 "hello.world () return java.lang.Stri"
當您等待下列事項之一發生時:
SQL> create or replace function helloworld return varchar2 as language java name 'hello.world() return java.lang.String';
2 /
已建立函數.
SQL> select helloworld from dual;
HELLOWORLD
--------------------------------------------------------------------------------
Hello world
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16381228/viewspace-754627/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16381228/viewspace-754627/