Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Java Procedure Doesn't Exist When Executed

Re: Java Procedure Doesn't Exist When Executed

From: Steve Howard <stevedhoward_at_gmail.com>
Date: 12 Jun 2006 08:01:44 -0700
Message-ID: <1150124504.903385.87570@f14g2000cwb.googlegroups.com>

Resant wrote:
> 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);
> }
> catch (IOException e)
> {
> System.err.println(e);
> }
> }
> }
> /
>
> 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

In addition to what Michael noted, and I'm sure this is just a newreader truncation error, make sure you add the on to the IOException throws clause.

Regards,

Steve Received on Mon Jun 12 2006 - 10:01:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US