I have created a java SP on oracle 8i to launch the excutable file . This SP works fine on WINDOWS NT/2000 plateform.
and when I execute this SP from the client machine it does the
the things which I wanted it, to do it.
When I created the SP on Oracle 8i running on HP/UX and pass the command line from sqlplus running on client machine(Windows 2000) it does nothing? I am puzzeled !!!! Why it does not execute the command on UNIX os any clue.
I am doing the following to create the SP's.
[1] Java program
Save this program in runj.java file.
import java.lang.*;
import java.io.*;
public class runj{
public static void runme(String strexe,String strdjs) {
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = { strexe, strdjs };
try {
Process child = rt.exec(callAndArgs);
child.waitFor();
//System.out.println("Process exit code is: " + child.exitValue());
}
catch(IOException e) {
//System.err.println( "IOException starting process!");
}
catch(InterruptedException e)
{//System.err.println( "Interrupted waiting for process!");
}
}
}
[2] Compile this program using the following command
loadjava -verbose -resolve -schema scott -user scott/tiger runj.java
Note: run this command from the directory where runj.java file resides.
Do not use system as schema in the above command it will give u an error.
[3] Create the following SP from the sqlplus
CREATE OR REPLACE PROCEDURE RUNEXE(str1 VARCHAR2,str2 VARCHAR2)
AS
LANGUAGE JAVA
NAME 'runj.runme(java.lang.String,java.lang.String)';
Originally posted by ashish23 I have created a java SP on oracle 8i to launch the excutable file . This SP works fine on WINDOWS NT/2000 plateform.
and when I execute this SP from the client machine it does the
the things which I wanted it, to do it.
When I created the SP on Oracle 8i running on HP/UX and pass the command line from sqlplus running on client machine(Windows 2000) it does nothing? I am puzzeled !!!! Why it does not execute the command on UNIX os any clue.
I am doing the following to create the SP's.
[1] Java program
Save this program in runj.java file.
import java.lang.*;
import java.io.*;
public class runj{
public static void runme(String strexe,String strdjs) {
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = { strexe, strdjs };
try {
Process child = rt.exec(callAndArgs);
child.waitFor();
//System.out.println("Process exit code is: " + child.exitValue());
}
catch(IOException e) {
//System.err.println( "IOException starting process!");
}
catch(InterruptedException e)
{//System.err.println( "Interrupted waiting for process!");
}
}
}
[2] Compile this program using the following command
loadjava -verbose -resolve -schema scott -user scott/tiger runj.java
Note: run this command from the directory where runj.java file resides.
Do not use system as schema in the above command it will give u an error.
[3] Create the following SP from the sqlplus
CREATE OR REPLACE PROCEDURE RUNEXE(str1 VARCHAR2,str2 VARCHAR2)
AS
LANGUAGE JAVA
NAME 'runj.runme(java.lang.String,java.lang.String)';
Here exp is oracle Export utility replace the schema name and table name according to your database set up.
Note : I AM USING MY DBA USER ID AND PASSWORD IN EACH AND EVERY STEP NOT THE SCOTT AND TIGER.
Please tell me that it works....
Thanks
Please mention your Oralce Version using on the Unix Environment. If you are using the Oracle 8.1.6 on Unix, there is a problem in the Oracle Server to Initialize the Runtime. You need to switch to either Oracle 8.1.5 or Oracle 8.1.6 for any Unix Platform and then try to execute, then U shall be successful in executing this program.
Oracle version is 8.1.7 and HP/UNIX11.
I run the program from UNIX prompt it gave me the return code 17 .This code is returned by the following command.
child.exitValue() in my java code
Hi,
Your example is good.. I tried running the example for a shell script on HP-UX
test.sh
#!/usr/bin/sh
echo HELLO
This works fine with exit code 0.
If I change it to
#!/usr/bin/sh
echo HELLO > /test/log.txt
cd /test/upload
export ORACLE_HOME=/product/oracle
sqlplus test/test@TESTDB @/test/upload/test.sql
test.sql contains
BEGIN
INSERT INTO msg_tbl values('hi there inserted');
commit;
END;
/
quit;
For this script I have a problem. Although the commandline shows PL/SQL procedure executed successfully, no rows are inserted to the table. However the message HELLO is found in log.txt..
Any pointers on what exactly could be the problem.
Not able to figure it out since the log.txt is getting created and it says proc executed but i dont see any rows.
Bookmarks