Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / 在PL/SQL中调用Java方法

1. 通过创建Java source的方式将Java class编译到数据库中create or replace and compile java source named xxfnd aspackage xxfnd;public class Test{public void Test(){}pubic static String helloWorld(){return "Hello, World!";}}2. 检查Java class是否编译成功show errors java source xxfnd;3. 创建PL/SQL测试程序包create or replace package test_pkg isfunction hello_world return varchar2;end test_pkg;/create or replace package body test_pkg isfunction hello_world return varchar2 islanguage java name "xxfnd.Test.helloWorld() return String";end test_pkg;/4. 编写plsq测试脚本begin
  dbms_output.put_line(test_pkg.hello_world);
end;
/此种方法可避免开发人员到服务器中编译java类并调用loadjava命令将java类载入系统中,所有的过程均在PLSQL客户端即可完成。