【发布时间】:2013-09-06 06:58:12
【问题描述】:
谁能帮我解决这个问题:我想从 Pl/SQL、Oracle RDBMS 调用一个 java 程序,以下是设置
Windows 7 机器,Java 安装在 C:\Program Files\Java\jdk1.7.0_02
我创建了一个目录来保存 java 文件。 D:\Java,里面有一个hello.java文件。
public class Hello
{
public static String world()
{
return "Hello world";
}
}
编译正常,在同一目录下生成了.class文件。
由于我必须使用 PL/SQL 调用此函数,所以这是我编写的 PL/SQL 函数:
create or replace
FUNCTION helloworld RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Hello.world () return java.lang.String';
这是 PL/SQL 过程:
create or replace
PROCEDURE hellow
AS
my_string varchar2(400 char);
begin
my_string:=helloworld();
dbms_output.put_line('The value of the string is ' || my_string);
end;
使用 SQL/developer 编译的函数和过程都很好。
当我尝试运行此程序时:
set serveroutput on;
execute hellow;
出现以下错误:
Error starting at line 2 in command: execute hellow Error report: ORA-29540: class Hello does not exist ORA-06512: at "ORACLE_SOURCE.HELLOWORLD", line 1 ORA-06512: at "ORACLE_SOURCE.HELLOW", line 5 ORA-06512: at line 1
29540. 00000 - "class %s does not exist"
*Cause: Java method execution failed to find a class with the indicated name.
*Action: Correct the name or add the missing Java class.
我也将 .class 文件放在 bin 文件夹中,但仍然出现同样的错误。 任何人都可以看看这个。
【问题讨论】: