oracle调用java方法的例子(下面所有代码都是在sql/plus

在oracle中调用java程序,注意:java方法必须是static类型的,如果想在JAVA中使用system.out/err输出log.

需要在oracle 中执行"call dbms_java.set_output(5000);".
一、helloWord
1 编写JAVA程序,也是在SQL/PLUS中写,并执行.

create or replace and compile java source named hello as
public     class   Hello    {
static    public    String Message(String name)    {
return     " Hello,   "    +    name;
}
}
/

2 发布JAVA程序

create or replace function hello (name VARCHAR2 )   return    VARCHAR2
as language java name
' Hello.Message (java.lang.String) return java.lang.String ' ;
/

3 使用发面的JAVA程序

select hello( ' world! ' ) from dual;
HELLO( ' world! ' )
-- -------------
Hello world!


本篇文章来源于:开发学院 http://edu.codepub.com   原文链接:http://edu.codepub.com/2010/0101/19273.php
原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100640.html