Hi All:

I am using windows 2000 server with Eclipse.
In the dost prompt, I ran the file run_sqlldrTest2.cmd and it loaded record into the Oracle database.
I tried to do the same thing in java calling the run_sqlldrTest2.cmd. In java it states the "The command line job - -executed successfully."
However, I donot see the record being loaded into the database.
What am I doing wrong?

If I comment out the "cmd[2]=set PATH=C:\\OraHome_1\\bin;" line and ran RunCmd.java, on the line for P.waitFor() it would freeze there forever:

Any help for suggestions would be greatly appreciated!!




import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class RunCmd 
	public static void main(String[] args)
		Process P;
		Runtime r;

        r = Runtime.getRuntime();

        try {
            String[] cmd = new String[4];
            cmd[0] = "cmd.exe";
            cmd[1] = "/C";
            cmd[2]="set PATH=C:\\OraHome_1\\bin;";

            try {
            	P = r.exec(cmd);
                int Exitcode = P.waitFor();
                if (Exitcode != 0) 
                    System.out.println("The command line job did not execute successfully");
                    System.out.println("The command line job - " + 
                             " - executed successfully."); //break
            catch (Exception e) 
            	System.out.println(" 1 e.getMessage():"+e.getMessage());

        } catch (Exception e) 
        	System.out.println("2 e.getMessage():"+e.getMessage());
set PATH=C:\\OraHome_1\\bin;
C:\test2009\scripts\run_sqlldr.cmd test2009/test2009@orcl control=C:\test\scripts\ctl\amcare.ctl log=C:\test\scripts\log\NAC20090150005112.txt.log data=C:\test\scripts\data\NAC20090150005112.txt bad=C:\test\scripts\bad_files\NAC20090150005112.txt.bad discard=C:\test\scripts\dis_files\NAC20090150005112.txt.dis;

echo %* > C:\test2009\scripts\log\sqlldr.log
sqlldr %* >> C:\test2009\scripts\log\sqlldr.log

Recommended Answers

All 2 Replies

Look a bit closer at the varying "exec" methods. One of them allows you to pass environment settings (read variables). The "exec" does not have a full environment, it is not a real shell. You need to pass the oracle_home, etc, variables to it's "shell" using the form of "exec" that allows you to do this.

hello in the above reply it is advised to put oracle_home and path values,can anyone provide me exact syntax to set all tha values. as i am not able to call sqlldr from application server as application server is connected to db server which donot have sqlldr.

so i want to use the sqlldr of local machine by setting oracle_home and path variable

i need it urgently
thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.