Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Java Procedure Doesn't Exist When Executed
I try this below script and the procedure created successfully, but
when I execute it from Oracle, it shows error :
class EXECCOMMAND does not exist
The code is :
DECLARE
RetVal NUMBER;
BEGIN
RetVal := TEST.EXEC_COMMAND('dir');
dbms_output.put_line(RetVal);
END;
Java Class:
import java.io.*;
public class ExecCommand
{
public ExecCommand()
{
}
static public int runCommand(String cmd) throws IOExcepti
{
// start command running
Process proc = Runtime.getRuntime().exec(cmd);
// wait for command to terminate
try
{
proc.waitFor();
}
catch (InterruptedException e)
{
System.err.println("process was interrupted"); return -1;
// check its exit value
if (proc.exitValue() != 0)
{
System.err.println("exit value was non-zero"); return -2;
// return success
return 0;
}
public static void main(String args[]) throws IOException
{
String cmdString = args[0];
System.out.println("command string is: " + cmdString);
try
{
//run a command int retVal = runCommand(cmdString); System.out.println("return value is: " + retVal);}
Function :
CREATE OR REPLACE FUNCTION EXEC_COMMAND(Command IN varchar2) RETURN
NUMBER AS
LANGUAGE JAVA
NAME 'EXECCOMMAND.runCommand(java.lang.String) return int';
/
Any wrong with the script?
Many thanks for any help given.
Resant Received on Mon Jun 12 2006 - 05:31:33 CDT