I am trying to load a csv file in oracle database using sql loader through java program. I have successfully executed it by run command, but i want to load csv file data in database through a java program. My programs are:
loadCsv.csv:
ID,firstName,LastName,Address 1,aditya,kumar,gaya 2,abhijeet,chanda,kol 3,Rahul,Jordar,kol
trial.ctl:
LOAD DATA INFILE loadCsv.csv BADFILE trial.bad DISCARDFILE trial.dsc APPEND INTO TABLE load1 FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY "”" (x,y,z,t)
SqlLoaderTest.java:
public class SqlLoaderTest { public static void main(String[] args) { try { String sqlldrCmd = "sqlldr control=E:\\load_data\\trial.ctl"+ "LOG=trial.log "+ "DATA=E:\\load_data\\loadCsv.csv USERID=vehere/adi"+ "BAD=E:\\load_data\\trial.bad"; System.out.println("SQLLDR Started ....... "); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(sqlldrCmd); System.out.println("SQLLDR Ended ........ "); } catch (Exception e) { e.printStackTrace(); } } }
It is compiled and run successfully but not inserting any data in database. your suggestion is highly appreciated.Thanx in advance.