Calling SQL Loader in Java

I am writing a Java application running on SUN Solaris to perform data feed from a number of csv files to ORACLE. I am to use SQL Loader to perform the loading. What I need is to kick off the SQL Loader in my code. My question is how to kick off the SQL Loader in Java.
One of option I am thinking is using RunTime.Exec(). Is the following code workable?
runtime.exec( "sqlldr CONTROL=foo.ctl, LOG=bar.log, USERID=scott/tiger" );
Althernatively should I write a Oracle store procedure to call the SQL Loader and Java call the store procedure?
Any thoughts and directions are welcome!
Regards,

Hi,
Can't you achieve the same thing using this
Class.forName("Driver");
Connection ocon=DriverManager.getConnection("url");
Once you have ocon then you can execute any query.
If this is not what you want,can you explain what SQLLoader means here?
Regards
Vicky

Similar Messages

  • How to Call SQL Loader from Java ( servlet )?

    We need to call SQL Loader command from Java Servlets? Any suggestions how this can be done?
    Thanks
    Rahul

    Probably not the best way, but you could try using JNI to call a C function which then invokes SQL Loader via system() or exec(). I haven't done this myself though...

  • Calling SQL LOADER From Java Program

    Hi
    I need to invoke sql loader from inside a Java Class.
    Any Pointers in this regards will be really appreciated.
    Thanks
    Vishal

    You can create two different files which has sqlldr command defined....
    1. loader.sh
    2. loader.bat
    and in the depending on the OS execute one...
             String command = "";
             if(System.getProperty("os.name").equals("Windows 2000")){
                    //if os is windows 2000  then execute bat file
                     command =  <<bat file path>>
              }else{
                      command = <<shell path>>
              Runtime rt = Runtime.getRuntime();
              Process p = rt.exec(command);
              int i = p.exitValue();
             

  • Calling oracle SQL Loader from java program

    Hi,
    I want to insert data into oracle tables from a text files containing fixed length fields. I am using SQLLoader to achieve this. The requirement is to call the SQLLoader within the java program.
    Does anyone know how to call SQL Loader from java program?
    Thanks,
    Varsha

    Simply "exec" the sqlldr program with the parameters you need to pass to it.
    Runtime.exec (........)
    Try to pass all parameters needed including the username and password, and use the option "silent" to avoid output, and the option "log" to have a log file of the modifications that sqlldr has done to the database.

  • Calling SQL*Loader from Forms

    Hi,
    I was wondering if anyone has called SQL*Loader from Forms?
    What I am wanting to do is use Oracle Forms as the interface where you can specify a file that you can import into the database and it will use a set control file. Push the import button and SQL*Loader does the rest.
    Is using Java code to call SQL*Loader from Forms a viable option, or is there an easier way to achieve the desired outcome.
    Any ideas or guidance will be much appreciated.
    Thanks,
    Scott.

    Scott,
    In forms, there's a HOST built-in command which is supposed to execute any o/s commands.
    What you have to do is :
    1. Bult up the string exacltly in the fashion which you will run in o/s
    2. Call the HOST Built-in and pass in the string
    Here's a example :
    Declare
    lOsCmd Varchar2(1000) := Null;
    Begin
    lOsCmd := 'sqlldr user-id=userid/passwd@connectStr '
    || ' control=c:\temp\abc.ctl log=c:\temp\abc.log '
    || ' bad = c:\temp\abc.log';
    Host (lOsCmd, No_Screen);
    End;
    -- Shailender Mehta --

  • Calling SQL * LOADER  in stored procedure

    Hi Experts,
    Can we call sql*loader in stored procedures? . If yes , please let me know the syntax.
    Any help will be highly appreciated.
    Thanks.

    You can also use dbms_schedular to execute any shell or batch file - i guess ->
    BEGIN
      -- UNIX
      DBMS_SCHEDULER.create_job(
        job_name             => 'unix_command_job',
        job_type             => 'EXECUTABLE',
        number_of_arguments  => 1,
        job_action           => '/bin/ls',
        auto_drop            => FALSE,
        enabled              => FALSE);
      DBMS_SCHEDULER.set_job_argument_value('unix_command_job',1,'/tmp');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'credential_name', 'TIM_HALL_CREDENTIAL');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'destination', 'marge.localdomain:65001');
      DBMS_SCHEDULER.enable('unix_command_job');
    END;For details ->
    http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
    http://www.oradev.com/dbms_scheduler.jsp
    http://www.psoug.org/reference/dbms_scheduler.html
    Regards.
    Satyaki De.

  • Calling sql loader in sqlplus

    Hi all, i am trying to load a file called text1.txt using sql loader. I am using sqlplus but i dont know how to call sql loader in sql plus.
    can someone provide syntax assumming data file is text1.txt and control file is txt.clt
    thanks

    Why on earth? Though you forgot to include version info, assuming you are not using 9i or older, you can and should use the external table facility and you don't need this unstable and resource consuming procedure.
    If you would have thought even one second about solving your own problem, you would have realized sqlloader is a separate O/S utility, which requires the host command, and username/password on the commandline.
    That alone is a reason not to do it.
    Sybrand Bakker
    Senior Oracle DBA

  • Help in calling sql loader and an oracle procedure in a script

    Hi Guru's
    please help me in writing an unix script which will call sql loader and also an oracle procedure..
    i wrote an script which is as follows.
    !/bin/sh
    clear
    #export ORACLE_SID='HOBS2'
    sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    sqlplus USERID=load/ps94mfo16 << EOF
    EXEC DO_TEST_SHELL_SCRIPT
    it is loading the data in to an oracle table
    but the procedure is not executed..
    any valuable suggestion is highly appriciated..
    Cheers

    multiple duplicate threads:
    to call an oracle procedure and sql loader in an unix script
    Re: Can some one help he sql loader issue.

  • Import and process larger data with SQL*Loader and Java resource

    Hello,
    I have a project to import data from a text file in a schedule. A lager data, with nearly 20,000 record/1 hours.
    After that, we have to analysis the data, and export the results into a another database.
    I research about SQL*Loader and Java resource to do these task. But I have no experiment about that.
    I'm afraid of the huge data, Oracle could be slowdown or the session in Java Resource application could be timeout.
    Please tell me some advice about the solution.
    Thank you very much.

    With '?' mark i mean " How i can link this COL1 with column in csv file ? "
    Attilio

  • Issues in calling Sql Loader through forms developer (10g)

    Hi,
    I am developing a form(in 10g) ,in which I am calling sql loader for loading data onto a oracle database table from external source (e.g. data file is a .CSV file).
    But , somehow the sql loader is not getting executed.
    Here , I am giving the environment settings , approach i am taking;
    This is a distributed system , both the application server,and database server are mounted on two different servers.
    The form is delpoyed on the application server.
    The database table , and the sql loader are configured on the databse side.
    I am using host(<sql loader command>) command to invoke the Operating System command through forms.
    The sql loader is working ok , and the data is getting loaded successfully onto the required database table when I am executing the sql loader command on Unix prompt , but through the forms , it's not working.
    Do I need to change some environmental setting to make this work...
    Any quick help in this regard is highly appreciated.
    Thanks.

    Hi Craig,
    I have already tried out the option of calling sql loader through stored procedure,but this is not working ...
    could you please share any examples to do so ...
    code snippet i am using in forms:
    declare
    usid get_application_property(userid);
    pwd get_application_property(password);
    db get_application_property(host);
    msqlldr varchar2(250);
    begin
    msqlldr:='/u01/oracle/formss/bin/sqlldr' username=<uid/pwd@db> control=<control file name> data=<data file name> log=<log file name>
    hosts(msqlldr);
    end;
    Note that sqlldr command ,for that matter any unix shell command is not working through the hosts() command ...
    could you please suggest any way out ...
    Thanks.

  • Calling SQL Loader with Dynamic file names

    HI all
    I woul like to know if I can call sql loader as below
    $ sqlldr userid=uname/pwd control=new.ctl, data=$1
    I have to schedule my loader 3 times a day and each time my file names are different(AAA_BBB_timestamp)
    Thanks

    I have found a solution myself and if any one is interested its like this
    for file in `ls -1 /opt/user/from/`
    do
    sqlldr userid=user/pwd@connect_string control=control_file.ctl data="/opt/user/from//$file"
    done
    Ramu

  • Calling Sql-loader from PL/SQL

    What is the command(s) to call Sql-Loader from inside a PL/SQL procedure?
    Regards,
    Ahmad.

    I don't think it is possible ...

  • Calling Sql*Loader from oracle Form builder

    How do i call sql* loader from my forms to import the external data in different formats into my existing database?
    Specify the flexibility of sql* loader to import external data from .txt files or .xls files.
    Would be thankful if certain examples are given along with the answer.

    Hi,
    1. First you have to create seperate ctl (Control files) which maps to different file formats
    2. Using Oracle Forms,
    2a) You can use the 'HOST' command to execute the command line ie. In this case executing
    SQL*Loader script
    2b) You also have the feature in ORACLE forms to read text files and load the data into
    ORACLE db.
    This can be achieved by using TEXT_IO package which comes with ORACLE Forms.
    Hope this helps
    Ta
    Shailender

  • Calling SQL Loader from Forms 4.5 using HOST command in Win2000

    One of my forms calls SQL Loader 7.3 using HOST command to load a csv file onto the database(Oracle 7.3) under Windows 2000 platform.
    Only after sql loader finishes its operation the control should come to my form i.e. synchronous execution.
    As of now its running asynchronously.
    Is there any way to make it synchronous. If Not any other work arounds?
    Environment Details
    Forms [32 Bit] Version 4.5.10.6.0 (Production)
    Windows 2000 Operating System
    Oracle7 Release 7.3.2.3.2

    Forms6i running on W2000, Rdbms 8.1.7
    in Forms I added a button TEST,
    Trigger when-button-pressed : host('test.bat') ;
    in directory .......\frm I added file test.bat :
    REM ===============
    cd /d C:\........\ldr
    pause
    sqlldr parfile=test.par
    pause
    type test.log
    pause
    exit
    REM ================
    now, pressing TEST button opens DOS window, telling me what's going on, running sqlldr, finally going back to forms
    Are you using NO_PROMPT or NO_SCREEN option of HOST command ?
    Had a look at Forms 4.5 manuals, there is no mentioning of (a)synchronously operation in connection with HOST command.

  • SQL Loader and Java

    Hi,
    I am using a Java Stored Procedure to invoke a SQL Loader process. The RDBMS Version is 8.1.7 on HP-UX 11. I invoke the procedure by calling: exec runcommand('sqlldr user=scott/tiger@orcl control=/home/mydir/ctlfile.ctl log=/home/mydir/logfile.log direct=true errors=550')
    where runcommand is the name of the java stored procedure.
    The SQL Loader process returns a value of 3 which is the return value for an Operating System Error. I am unable to find any errors related to the Operating System. Is there any particular environment variable which needs to be set before running the process.
    I was able to run the same Java Stored Procedure on Personal Oracle on Windows XP without any problems.
    TIA,
    Ramesh

    Hi,
    Make sure that the path for data file in control file is correct.
    Then it serves your purpose.
    Otherwise, give full path to "sqlldr", then run it.
    Please let me know the result.
    Thanks
    Srinivasa Rao

Maybe you are looking for

  • Routine in InfoPackage for flatfile loading

    Hi Friends, Can you give be possiblesolution for my scenario. I am getting a flatfile from a Third Party source and I am loading the data into a Cube. Recently, we have identified that we are getting duplicate data in the file for the same week.And I

  • Drop Down in PHP

    I know in Coldfusion you can place a list in your form that shows a drop down of all your uploaded audios in a folder. <cfdirectory action="list" directory="/audios/productAudios/" name="rsAudios" sort="name"/> The form can be like...(sample) <form>

  • SOA Suite BPEL to OSB

    I am trying to create a simple proof of concept that calls OSB from a BPEL Process. I created a WSDL with an EchoService in OSB, I then created a partner link with the WSDL. When using the BPEL Debug Console I get an error: Faulted while invoking ope

  • Backed up data dvd-rw will not mount on my desktop?

    a few months ago, i used retrospect to backup files onto five verbatim dvd-rw disks. the backups went fine and after they each were done i checked them to make sure that the backup was successful (which in all cases it was). recently i wanted to upda

  • Default browser in Windows...

    You know, I am just amazed that Safari 4 still...still cannot correctly set itself as the default browser in Windows. Nothing but love for Apple, but...why... In the beta of 4, selecting Safari as the default browser in the Safari settings or in the