Insert into database from flat file
Hi, I am trying to insert the contents of a flat file into table. To connect to database i am using JDBC driver. I the problem i am facing is the contents of flat file is being inserted into table only for the first time when i run the program, again when i try to insert into it( even though table is empty) i am getting an error message.
Can anyone help me in this regard.
Thanks in advance.
program to insert into table:
Code Java:
public void doWork (String s) throws Exception{
String [] ar = s.split("\\-");
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(url,userName,password);
String queryString = "INSERT INTO feeds ( subject,time,creator) values('"+ar[0]+"','"+ar[1]+"','"+ar[2]+"')";
stmt=con.createStatement();
val = stmt.executeUpdate(queryString);
}
catch(Exception e)
{
System.out.println("e : " + e);
}
}
Error message I am getting again when i run the program:
Re: Insert into database from flat file
Are you sure you have the JDBC driver installed correctly? It doesn't look like it can find it..
Re: Insert into database from flat file
I had not included jdbc jar file... Thanks. Its working now.