1

We are trying to load a huge file (say ~1 GB size) into an Oracle database via SQL Loader. I have created a Java program which will execute the SQLLoader command from the program and loader will load the file into the table.

My Code:

  public void invokeSQLLoader(){

    String stringCommand="/usr/lib/oracle/18.3/client64/bin/sqlldr <userId>/<password>@<dburl> control=/u01/hmpoc/HM_EDW_PASSBACK.ctl data=/u01/hmpoc/Passback_Report.csv bad=/u01/hmpoc/PASSBACK.bad discard=/u01/hmpoc/PASSBACK.dsc log=/u01/hmpoc/PASSBACK.log ERRORS=1000000";

    System.out.println("Passing Command::"+stringCommand);

    Process proc = null;

    try {
            System.out.println("Starting procedure call---"+new java.util.Date());

            Runtime rt = Runtime.getRuntime();
            proc = rt.exec(stringCommand.trim());

            System.out.println("End Procedure call---"+new java.util.Date());

    }catch (IOException e) {
            e.printStackTrace();
    } catch (NullPointerException e) {
            e.printStackTrace();
    }/*finally {
            proc.destroy();
    }*/
    System.out.println("SQLLDR Ended");
}

Question and query to all the experts:

  1. When the file size is ~ 40 MB , we can load data via my Java program.

  2. When the file size > 42 MB , Java program runs successfully but data not get loaded with the file. No error or exception shown in the Java console. Where as if I ran the same command from command prompt with same control file and data file it is getting loaded.

Can anyone please help me? If I am missing something or what is the best way to invoke sqlloader from Java program apart from my approach.

7
  • 1
    Try adding proc.waitFor() to wait until the command is finished (assuming the command doesn't start it's own thread and returns immediately).
    – Andrew S
    Oct 11, 2018 at 19:04
  • I made the method as Asynchronous so that it can take his own time but as you suggested will try to add for wait() and check.
    – Arijit
    Oct 11, 2018 at 19:07
  • 1
    You don't seem to be consuming the output and error stream of the process, this can sometimes lead to the application blocking if it actually writes output and the output exceeds the buffer. Oct 11, 2018 at 20:00
  • @MarkRotteveel If you follow the command carefully you could see we are consuming logs and errors as Bad file in unix box directly.
    – Arijit
    Oct 11, 2018 at 20:03
  • And are you sure it doesn't output anything to the standard output and error? To be perfectly clear: I don't know sqlldr, I just know that this (not consuming the streams) can sometimes be a problem. Oct 11, 2018 at 20:06

1 Answer 1

0

I got the answer. I did not make any changes in my above mentioned Java code. I have only added DIRECT=TRUE in my control file. It works. Now I am able to load till 1 GB size file.

Thanks all who read my problem and tried to give answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.