加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

在PL/SQL中调用Java技巧

发布时间:2021-11-22 12:39:30 所属栏目:教程 来源:互联网
导读:1. 通过创建Java source的方式将Java class编译到数据库中 create or replace and compile java source named xxfnd as package xxfnd; public class Test{ public void Test(){ } pubic static String helloWorld(){ return Hello, World!; } } 2. 检查Java

1. 通过创建Java source的方式将Java class编译到数据库中
 
create or replace and compile java source named xxfnd as
package 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 is
  function hello_world return varchar2;
end test_pkg;
/
create or replace package body test_pkg is
  function hello_world return varchar2 is
    language 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客户端即可完成。

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读