Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    11

    Red face Unanswered: How to call Oracle sqlldr in Java

    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!!

    Yours,

    Frustrated.



    RunCmd.java:

    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;";
    cmd[3]="C:\\nacrs2009\\scripts\\run_sqlldrTest2.cmd";



    try {
    P = r.exec(cmd);
    int Exitcode = P.waitFor();
    if (Exitcode != 0)
    {
    System.out.println("The command line job did not execute successfully");
    }
    else
    {
    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());
    }
    }
    }

    run_sqlldrTest2.cmd:
    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.tx t.bad discard=C:\test\scripts\dis_files\NAC2009015000511 2.txt.dis;

    run_sqlldr.cmd:
    echo %* > C:\nacrs2009\scripts\log\sqlldr.log
    sqlldr %* >> C:\nacrs2009\scripts\log\sqlldr.log

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    However, I donot see the record being loaded into the database.
    Did you check SQL*Loader's LOG file? What does it say?

  3. #3
    Join Date
    May 2009
    Posts
    11
    Hi:

    Thank you for the quick reply.
    There was no sql loader log file being created when I tried to call sqlldr in java.
    There were sql loader log file created If I called sql loader in dos-prompt.

    Yours,

    Frustrated.

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    It might be because ORACLE_HOME is/was not set.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •