Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> SQL*Loader spawn from java
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C01688.54548E70
Content-Type: text/plain;
charset="iso-8859-1"
Hi,
We've written a small Java code to start SQL*Loader from the JVM.
Seems that we are having a very strange reaction doing so - the Loader getting stuck after insertion of few records (100-200). The same Loader with all the params works fine from the command prompt env.
We're using 8.1.5 rdbms/clients, both client and server NT.
Any of you familiar with this?!
Ronen Levit
Database group manager
Talmai
Tel: +972 8 9460606 #212 Fax: +972 8 9460705 Cell: +972 52 448699
Attached is the java program .
It gets the following parameters :
0 - Data file name 1 - Control file name 2 - Oracle user name 3 - Oracle's user password 4 - Oracle's connect string 5 - Sql*Loader command (e.g. sqlldr) 6 - Indication either to use direct load or not
for example :
java com.talmai.cms.test.TestSqlLoader x.dat x.con scott tiger orcl.world
sqlldr false
The direct load works fine ,
though using the Sql*Loader without the direct load , the
program gets stuck approximately after 124-128 records
(depends on the records size I guess).
<<TestSqlLoader.java>>
------_=_NextPart_000_01C01688.54548E70
Content-Type: application/octet-stream;
name="TestSqlLoader.java"
Content-Disposition: attachment;
filename="TestSqlLoader.java"
package com.talmai.cms.test;
import java.lang.*; import java.io.*; import java.util.*;
public class TestSqlLoader {
private String fileName; private String controlFile; private String userId; private boolean isDirect; private String loaderCommand;Received on Mon Sep 04 2000 - 10:53:55 CDT
/* This program tests invocation of Sql*Loader from Java */
/* Parameters : */
/* 0 - Data file name */
/* 1 - Control file name */
/* 2 - Oracle user name */
/* 3 - Oracle's user password */
/* 4 - Oracle's connect string */
/* 5 - Sql*Loader command (e.g. sqlldr) */
/* 6 - Indication eather to use direct load or not */
public static void main(String args[]) { String file = args[0]; String control = args[1]; String user = args[2]; String pwd = args[3]; String connectStr = args[4]; String command = args[5]; Boolean direct = new Boolean(args[6]); TestSqlLoader testSqlLoader = new TestSqlLoader(file,control,user+"/"+pwd+"@"+connectStr, command,direct.booleanValue()); testSqlLoader.loadFile(); } public TestSqlLoader(String fName ,String control,String uid,String sqlLoaderCmd, boolean directLoad) { fileName = fName; controlFile = control; userId = uid; loaderCommand = sqlLoaderCmd; isDirect = directLoad; }
/* Public method to load the desired file into the database */
/* via the Sql*loader . Direct path will be used if desired */
public void loadFile() { int subProcessRc; String loadStmt; boolean rc = true; char[] cbuf = new char[1000]; try { /* Building the load stmt.*/ loadStmt = loaderCommand + " userid=" + userId + " data=" + fileName + " control =" + controlFile + " log = " + fileName.substring(0,fileName.length()-3) + "log"; if (isDirect) loadStmt = loadStmt + " direct = " + isDirect; System.out.println(loadStmt); /* Execute the load stmt in a different subprocess */ Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(loadStmt); subProcessRc = pr.waitFor(); } catch (InterruptedException e) { e.printStackTrace();
![]() |
![]() |