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.

Similar Messages

  • 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 C code (exe ) from Java program

    Hi all,
    kindly help in giving a solution for calling C code (exe ) from Java program, i will be very thank full to u if any body can help in sending a code example
    bye

    You might need to consume the io operations on the Process...
    An excerpt from java.lang.Process:
    All its standard io (i.e. stdin, stdout, stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream(), Process.getInputStream(), Process.getErrorStream()). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.

  • Problem in calling Oracle stored procedure from Java.

    I am trying to invoke the Oracle stored procedure from Java. The procedure does not take any parameters and does not return anything. If I call it from SQL prompt it is working perfectly. I am calling it in my program as follows.
    callable_stmt=con.prepareCall("{call pkg_name.proc_name()}");
    callable_stmt.execute();
    The problem is the control-of-flow is getting strucked in the second line I wrote. It is not giving any error also.
    Please clarify me what's wrong with my code?
    Seenu.

    And how long does the stored procedure take to run from your client machine when running it via sqlplus?

  • Error PLS-00306 during calling PL/SQL function from Java

    Hi all,
    I am facing a problem during call of oracle PL/SQL function from java using CallableStatement.
    I receive following error message.
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    As per above error EXPORT_HIST_ALARMS_FUNC in oracle has this signature.
    CREATE OR REPLACE FUNCTION EXPORT_HIST_ALARMS_FUNC(startDateTime VARCHAR2, endDateTime VARCHAR2, meType VARCHAR2) RETURN VARCHAR2 IS
    END EXPORT_HIST_ALARMS_FUNC;
    Above function I have called following way in java.
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(2,startDateTime);
    cStatement.setString(3,endDateTime);
    cStatement.setString(4,meType);
    cStatement.execute();
    msg = cStatement.getString(1);
    Actually above function requires three input parameters and one return parameter.
    During execution of above java code it throws SQLException and shows PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC' error.
    I have run this function directly from oracle with three parameters and run successfully and finally it returns string.
    But I am unable to figure out why it doesn't run from above java code.
    Please help regarding this.
    Thanks.
    Regards,
    Shardul Banker

    Try this:
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(1,startDateTime);
    cStatement.setString(2,endDateTime);
    cStatement.setString(3,meType);
    cStatement.execute();
    msg = cStatement.getString(1);Regards,
    Martijn Teigeler
    Edited by: mTeigeler on Oct 13, 2007 10:22 AM

  • Calling PL/SQL Procedures from Java

    Hello,
    I want to know, if it is possible to call PL/SQL Procedures from
    SQLJ(which uses htp.print from the Package web toolkit ).
    Though, it is possible to call normal procedures but if I want
    to call PL/SQL procedures with htp.print then I get I error.
    For example:
    #sql{Call html_test()};
    Can you give me a advice?
    Your help is much appreciated!
    M|ller

    Oracle's htp packages are develop to be work with
    mod_plsql/OAS/OWS webserver.
    If you are trying to use htp packages first need to instanciate
    some enviroment vars for htp packages, for example first you has
    to call to owa.initialize procedure, populate owa.cgi array and
    so on.
    If you need more information about how this toolkit works you
    could get the source of DB Prism at
    http://www.plenix.com/dbprism/ this open source framework
    includes backward compatibility with mod_plsql application and
    then includes settings of this values from Java code.
    Best regards, Marcelo.

  • 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...

  • Problems in SQL Connection from Java program to Oracle 8.1.7

    Hi,
    I am java program that connects to Oracle 8.1.7 .
    Client: java code on Windows 2000
    Server: oracle 8.1.7 on Solaris
    Java code uses two types of Connection Pools. One Pool uses "thin" connections and other pool uses "OracleConnectionPoolDataSource" class.
    The methods which use "thin" pool work great however the methods which use "OracleConnectionPoolDataSource" fail after 5 to 10 calls.
    Given below is the exception that I see in my log file.
    February 26, 2002 10:17:38 AM UTC: Debug.INFO: searchByNameCommono.jsp Error : Tpd2.openConnection(1)failed:DBConnPool2.getConnection(String) failed:Closed Connection
    com.commerceone.msbtpdapi.util.DBConnException: Tpd2.openConnection(1)failed:DBConnPool2.getConnection(String) failed:Closed Connection
         at com.commerceone.msbtpdapi.api.Tpd2.openConnection(Tpd2.java:138)
         at com.commerceone.msbtpdapi.api.TpdDBApi.searchTpsByCompanynameAndStatus(TpdDBApi.java:1685)
    Windows java code uses JDK 1.3.1
    Oracle machine has java version 1.2.2.
    Do I need to check for any settings like LD_LIBRARY_PATH on oracle machine ?
    Thanks a lot.
    Regards
    Mandar

    Hi,
    I am java program that connects to Oracle 8.1.7 .
    Client: java code on Windows 2000
    Server: oracle 8.1.7 on Solaris
    Java code uses two types of Connection Pools. One Pool uses "thin" connections and other pool uses "OracleConnectionPoolDataSource" class.
    The methods which use "thin" pool work great however the methods which use "OracleConnectionPoolDataSource" fail after 5 to 10 calls.
    Given below is the exception that I see in my log file.
    February 26, 2002 10:17:38 AM UTC: Debug.INFO: searchByNameCommono.jsp Error : Tpd2.openConnection(1)failed:DBConnPool2.getConnection(String) failed:Closed Connection
    com.commerceone.msbtpdapi.util.DBConnException: Tpd2.openConnection(1)failed:DBConnPool2.getConnection(String) failed:Closed Connection
         at com.commerceone.msbtpdapi.api.Tpd2.openConnection(Tpd2.java:138)
         at com.commerceone.msbtpdapi.api.TpdDBApi.searchTpsByCompanynameAndStatus(TpdDBApi.java:1685)
    Windows java code uses JDK 1.3.1
    Oracle machine has java version 1.2.2.
    Do I need to check for any settings like LD_LIBRARY_PATH on oracle machine ?
    Thanks a lot.
    Regards
    Mandar

  • Loading huge file with Sql-Loader from Java

    Hi,
    I have a csv file with aprox. 3 and a half million records.
    I load this data with sqlldr from within java like this:
               String command = "sqlldr userid=" + user + "/" + pass
                        + "@" + service + " control='" + ctlFile + "'";
                System.out.println(command);
                if (System.getProperty("os.name").contains("Windows")) {
                    p = Runtime.getRuntime().exec("cmd /C " + command);
                } else {
                    p = Runtime.getRuntime().exec("sh -c " + command);
                }it does what I want to, load the data to a certain table, BUT it takes too much time, Is there a faster way to load data to an oracle db from within java?
    Thanks, any advice is very welcome

    Have your DBA work on this issue - they can monitor and check performance of SQL*Loader
    SQL*Loader performance tips          [Document 28631.1]
    SQL*LOADER SLOW PERFORMANCE          [Document 1026145.6]
    Master Note for SQL*Loader          [Document 1264730.1]
    HTH
    Srini

  • Jdbc NullPointerException calling pl/sql procedure from java

    Hi.
    Getting the following exception calling a plsql procedure from jdbc.
    - Jdbc version is 10.2.0.2, but it also happens running several other variants, including 10.1.0.5.0.
    - Application is running in Weblogic 8.1.3 (8.1 SP 3).
    The procedure call itself has 2 in/out parameters which are tables (actually just 1 dimensional arrays), which I'm suspecting has something to do with the problem. I can successfully call this procedure using a plsql developer tool with the same bind parameters.
    Any ideas?
    Exception encountered while executing PL/SQL procedure MVT_Web_Inquiry.ShowInquiry:
    java.lang.NullPointerException at oracle.jdbc.driver.T4CTTIiov.processRXD([Loracle.jdbc.driver.Accessor;I[B[C[SILoracle.jdbc.driver.DBConversion;[B[B[[Ljava.io.InputStream;[[[B[[Loracle.jdbc.oracore.OracleTypeADT;Loracle.jdbc.driver.OracleStatement;[B[C[S)[Loracle.jdbc.driver.Accessor;(T4CTTIiov.java:139)
    at oracle.jdbc.driver.T4C8Oall.receive()V(T4C8Oall.java:521)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(ZZZZ)V(T4CCallableStatement.java:215)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(Z)V(T4CCallableStatement.java:1119)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:1278)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal()I(OraclePreparedStatement.java:3446)
    at oracle.jdbc.driver.OraclePreparedStatement.execute()Z(OraclePreparedStatement.java:3552)
    at oracle.jdbc.driver.OracleCallableStatement.execute()Z(OracleCallableStatement.java:5261)
    at weblogic.jdbc.wrapper.PreparedStatement.execute()Z(PreparedStatement.java:70)
    at
    [snip]

    OK... I figured it out.
    Apparently, this error happens when you forget to register the output part of an in/out parameter. I would have hoped for better error messaging, but oh well.
    -ed-

  • Calling Oracle stored procedure from java

    The following query calls a stored procedure TRANSLATE_ZONEPATH_ID defined in a package MT by the user MTDBA. currentZone is a member variable of the class, and currently has value 1
    This query works just fine when I run it from SQLPlus* connected as MTDBA.
    But from java, the following piece throws exception saying "invalid column name"
    String query = "SELECT MTDBA.MT.TRANSLATE_ZONEPATH_ID('"+currentZone+"') "
    + "FROM DUAL ";
    try
    Statement stmt = conn.createStatement();
    ResultSet rst = stmt.executeQuery(query);
    if (rst.next())
    fullName = rst.getString(1);
    stmt.close();
    Anyone got any clue ?

    I always use CallableStatement to execute a stored procedure or function in a database (Oracle).
    try this:
    <code>
    CallableStatement cs = dbConnection.prepareCall("{ ? =
    MTDBA.MT.TRANSLATE_ZONEPATH_ID(?)}");
    cs.setString(1, currentZone);
    cs.registerOutParameter(1, Types.VARCHAR);
    cs.executeUpdate();
    fullname = cs.getString(1);
    cs.close();
    </code>
    There is also a jdbc forum, where your should post this kind of problem :-)
    Hope this help's
    ThK

  • Executing sqlldr (sql loader) from java and returning the error code

    I'm wandering do sqlldr return any error code whenever it hit error while running in java.
    For example, if i run in command prompt using the command below,
    C:\ >sqlldr uid/pwd data=abc.dat control=abc.txt
    It might give me some indicator that error occurs such as
    SQL*Loader-601: For INSERT option, table must be empty. Error on table CURRENCY
    or
    SQL*Loader-500: Unable to open file (abc.txt)
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: The system cannot find the file specified.
    But when i run in java using the code below,
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("sqlldr uid/pwd data=abc.dat control=abc.txt");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    it will only give me the same exitValue of 1(i presume its error) / 0 (i presume no error) instead of the details of the error.
    How can i get the exact error code/message if i were to execute it using java?
    Any solution?

    mg,
    I don't think user576271 wants the exit code, I think [s]he wants the error message.
    But wouldn't error messages from SQL*Loader be sent to the stderr stream, and not the stdout stream?
    In which case user576271 would need method "getErrorStream()" of class java.lang.Process, no?
    Good Luck,
    Avi.

  • How to call a perl module from Java program.

    Hi,
    I create a simple java program as follows
    class test{
    public static void main(String args[])
    {try {                    
    Runtime r = Runtime.getRuntime();
    r.exec("perl test.pl");
    catch(Exception e)
    {e.printStackTrace();}
    and test.pl is located in the same directory as the java program. The program compiles but with no return as I execute it. I am not sure what is wrong.
    Thanks,

    I think the wrong line is here; r.exec("perl test.pl");
    Usually the JVM needs the full path.If the path for either the executable or the script was wrong then, given the code posted, it would not hang.
    >
    To automatticaly get the path (if the file is in the
    class path) use
    System.getProperty("java.class.path")
    That gets paths(plural).
    Try this:
    r.exec("perl " +
    System.getProperty("java.class.path") + "\test.pl");I am rather certain that that won't work on any standard operating system.

  • Getting exception whil calling an oracle stored procedure from java program

    Dear All,
    I encounter this error in my application when I call only the stored procedure but the view is executing fine from the application and my environment is as follow:
    Java 1.4
    oracle 10g
    oracle jdbc driver:9.2.0.8.0
    websphere portal 6.0.0.1
    this error is occur from time to time randomly, when it happens, the only workaround is to restart the server..Does anyone have any idea about this error?
    Unable to execute stored Procedure in Method
    java.lang.NullPointerException
    at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1140)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    And sometime I am getting this exception
    Unable to execute stored Procedure in Method
    java.lang.ArrayIndexOutOfBoundsException: 27787320
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1134)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    Thanks
    Jay

    spacetorrent escribi&oacute;:
    for (int x=0; x <result.size(); x++){
    System.out.println(result.get(x));
    I can't do this, because result object is a Map, and I need write the Key of the Value to obtain.
    So I can do:
    result.get("res");And I odtain a *$Proxy3* Object

  • Problem Calling Oracle Stored Procedure From JAVA

    Hello all. I've been banging my head against this all day:
    Here's the procedure I'm calling:
    GetIDsByLatLonRadius(inLatitude IN NUMBER,
    inLongitude IN NUMBER,
    inRadius IN NUMBER,
    inTableName IN VARCHAR2,
    inIDColName IN VARCHAR2,
    inLatColName IN VARCHAR2,
    inLonColName IN VARCHAR2,
    LocationIDs OUT HomesCom_Types.GenericCursorType,
    ErrorNo OUT VARCHAR2);
    And here's the JAVA code:
    public Hashtable GetInRadius(Hashtable inStruct)
    ResultSet locationIDs = null;
    Hashtable outputHash = new Hashtable();
    float latitude = (float) 30.429;
    float longitude = (float) -84.2585;
    float radius = (float) 10;
    try {
    CallableStatement proc = con.prepareCall("{ call GEOCODING.getidsbylatlonradius(?,?,?,?,?,?,?,?,?) }");
    proc.setFloat(1,latitude);
    proc.setFloat(2,longitude);
    proc.setFloat(3,radius);
    proc.setString(4,"demographics_school");
    proc.setString(5,"onboard_id");
    proc.setString(6,"geocoding_latitude");
    proc.setString(7,"geocoding_longitude");
    proc.registerOutParameter(8,OracleTypes.CURSOR);
    proc.registerOutParameter(9,OracleTypes.VARCHAR);
    proc.execute();
    locationIDs = (ResultSet) proc.getObject(1);
    if (locationIDs != null)
    outputHash.put("query",locationIDs);
    else
    outputHash.put("query","LOCATION ID WAS NULL");
    catch(SQLException sqlException) {  
    System.out.println(
    "The following error occured in reading " +
    "from the table: "
    + sqlException);
    outputHash.put("error",sqlException.getMessage());
    return outputHash;
    This catches and the sqlException I get is: Unhandled sql type
    I'm not a java expert and I'm completely stuck at this point, so I figured a few more eyes on it might help.
    Thanks in advance,
    Danny

    Danny,
    Don't print merely the error message, print the whole stack trace.
    Then post it here.
    What java version are you using?
    What JDBC driver and version are you using?
    What Oracle database version are you using?
    Is the code from a Java ServerPages (JSP) or from a Java Stored Procedure (JSP)?
    I guess "HomesCom_Types" is one of your PL/SQL packages or routines, right?
    If so, then you can't use it in JDBC, you must define a database type using the command:
    create or replace type ...But in later versions of the Oracle database, the REF CURSOR type is built-in.
    Check the Oracle documentation for more details.
    Good Luck,
    Avi.

Maybe you are looking for

  • Need Help with Simultaion for a Solar cell simulation

    hello, I want to simulate a Solar Cell in Multisim and i already entered the cirquit for a solar cell. However i have a problem with the simulation. i want to vary the load and the input power to see how the output voltage varys, as a function of inp

  • Error in SAPGUI-on AIX- Can't load JNI library

    Error in SAPGUI-on AIX- Can't load JNI library I am getting error as below: ^C# ./sapgui /H/punlparidm06 /S/sapdbIND ERROR ############################# 07.03. 12:48:37.619 ERROR: Attempt to load shared library /local/SAPClients/SAPGUI7.00rev2.1/bin/

  • Splitter container

    Hi Friends, I am not able to get the output for the report which is shown below. Can anybody solve the my problem? Thanks, REPORT ZREPORT10 . DATA:  splitter TYPE REF TO cl_gui_splitter_container,        alv_list1 TYPE REF TO cl_gui_alv_grid,       

  • Wikis Webclip icon

    I use a profilemanager to create a Webclip of my Wikis, changes the icon according the my needs. When the profile pushed to ipads, the icon is fine. But after i entered the webclip to see the web, then it changes to Wikis icon. I want to know why and

  • How to sent notification to a user depending on some condition?

    Hi All, I am working in iRecruitment Recruiter responsibility->iRecruitment Recruiter->Candidate I have an requirement that for a particular applicant if HR is taking Interview and he forgot to add feedback.Then a notification has been sent to him af