简体   繁体   中英

Error on Oracle : ORA-29541

I'm trying to call a bash script within a oracle database through a java script. To test it I just tried a basic script :

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

And the java script that I use is :

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

that will generate compiled class with .class extension. For your case it will be 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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