Trigger SQL Loader from Java

In this post, we will see how to invoke SQL Loader from Java..Piece of cake and this is not the only method to accomplish this task. Here is a simple sample code that invokes SQL Loader from a Java code..This can be extended to JSP / Java based applications.

import java.util.*;
public class image {
public static void main(String[] args){
Runtime Rt;
Process Prc;
String cmd = "";
cmd ="sqlldr userID/password@DB control=cntr.ctl log=log1.log" ;
Rt = Runtime.getRuntime();
try {
Prc = Rt.exec(cmd);}
catch(Exception exception)

This can be executed in a standard way as we do for any other Java code. This will trigger SQL Loader and rest of the behaviour will be as per the SQL Loader documentation…

1 comment:

  1. Excellent, I was trying to call SQL Loader from Java and this post really helped..I had to stuff in some more code for my requirement, but was successful to invoke SQL Loader through my Java application.