简体   繁体   English

Oracle上的错误:ORA-29541

[英]Error on Oracle : ORA-29541

I'm trying to call a bash script within a oracle database through a java script. 我试图通过Java脚本在oracle数据库中调用bash脚本。 To test it I just tried a basic script : 为了测试它,我只是尝试了一个基本的脚本:

#!/bin/bash
echo "It works !"

And the java script that I use is : 我使用的Java脚本是:

import java.lang.*;
import java.io.*;

public class UAM_TOOLS{

    public static String Toto ()  throws IOException {
    String[] unixCommand = {"/home/oz380/toto.sh"};
    String pwd;
    Process p = Runtime.getRuntime().exec(unixCommand);
    BufferedReader input =
            new BufferedReader
            (new InputStreamReader(p.getInputStream()));
    pwd = input.readLine();
    input.close();
    return pwd;
    }
};

I granted all the permissions that had to be granted and I created the function in my database : 我授予了所有必须授予的权限,并在数据库中创建了该函数:

SQL> CREATE OR REPLACE FUNCTION TOPI RETURN VARCHAR2
  2  as language java
  3  name 'UAM_TOOLS.Toto() return java.lang.String';
  4  /

But then when I call the function : 但是然后当我调用函数时:

select TOPI from dual;

or : 要么 :

SQL> set serveroutput on;
SQL> DECLARE
  2  G VARCHAR2(50);
  3  BEGIN
  4  G := UAM.TOPI;
  5  DBMS_OUTPUT.PUT_LINE(G);
  6  END;
  7  /

It doesn't work and prints the error : 它不起作用并显示错误:

ORA-29541: class UAM.UAM_TOOLS could not be resolved

I don't really understand what the problem can be. 我真的不明白问题可能是什么。 If anyone does I would be really thankful. 如果有人这样做,我将非常感激。

Before the 之前

CREATE FUNCTION 创建功能

step you need to compile your class at command line 步骤,您需要在命令行上编译您的类

$>javac UAM_TOOLS.java

or using an IDE sth like Eclipse 或使用Eclipse之类的IDE

that will generate compiled class with .class extension. 将会生成扩展名为.class的编译类。 For your case it will be UAM_TOOLS.class 对于您的情况,它将是UAM_TOOLS.class

And you still need to upload it to database on command line where the host which db runs on it 而且您仍然需要通过命令行将其上载到数据库,在该数据库上运行数据库的主机

$>loadjava -user yourUserName/youPass@Yourdb UAM_TOOLS.class

after that 2 step you can resume with create function step. 在这两个步骤之后,您可以继续执行创建功能步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM