标签:
1.直接在 SQL Developer中写入代码
create or replace and compile java source named "HelloWorld"
as
package com.test;
public class HelloWorld {
public static String sayHello(String name){
return "hello::"+ name;
}
}
2.创建一个方法或包调用 JAVA
(1).方法
create or replace function HelloWorld(p_name in varchar2) return varchar2 as language java name ‘com.test.HelloWorld.sayHello(java.lang.String) return java.lang.String‘;
(2).包
--包头
create or replace package PHelloWorld is function hello_world(p_name in varchar2) return varchar2; end PHelloWorld; --包体 create or replace package body PHelloWorld is function hello_world(p_name in varchar2) return varchar2 is language java name ‘com.test.HelloWorld.sayHello(java.lang.String) return java.lang.String‘; end PHelloWorld;
3.调用方法或包,相当于调用JAVA
(1).调用方法
begin htp.print(HelloWorld(‘xx‘)); end;
(2).调用包
begin htp.print(PHelloWorld.hello_world(‘xx‘)); end;
完毕!
标签:
原文地址:http://www.cnblogs.com/ser0632/p/4914932.html