Uploading to mySql Database
Dear friends,
I am unable to upload data from a text file to a mysql database using the LOAD DATA INFILE.... sql query in Java.
The following is the code snippet.
/***************/
query = "LOAD DATA INFILE C:\\TestParse1.txt INTO TABLE excelData FIELDS TERMINATED BY ,";
System.out.println(query);
Statement newStmt = con.createStatement();
res2 = newStmt.executeUpdate(query);
/*************/
Could anybody help me out in this? It is showing a message as output which says that there's some error in my SQL syntax.
Subhash
well according to the mysql manual, there should be quotes around the filename and the terminator.
query = "LOAD DATA INFILE 'C:\\TestParse1.txt' INTO TABLE excelData FIELDS TERMINATED BY ','";
http://dev.mysql.com/doc/refman/5.0/en/load-data.html
Earlier i had tried using those quotes but then it was showing me this error: 'C:TestParse1.txt' not found (Errcode: 2) though the file TestParse1.txt is present in C:. what could be the remedy for this?
I shifted to the modified query(minus the quotes) only to avoid this.'
subhash
Message was edited by:
subhashmedhi