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

[595 byte] By [subhashmedhia] at [2007-11-27 10:42:12]
# 1

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

gimbal2a at 2007-7-28 19:17:02 > top of Java-index,Java Essentials,Java Programming...
# 2

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

subhashmedhia at 2007-7-28 19:17:02 > top of Java-index,Java Essentials,Java Programming...
# 3

Could anybody help me out?

subhashmedhia at 2007-7-28 19:17:02 > top of Java-index,Java Essentials,Java Programming...
# 4

http://www.exampledepot.com/egs/java.sql/LoadFileToMySqlTable.html

subhashmedhia at 2007-7-28 19:17:02 > top of Java-index,Java Essentials,Java Programming...
# 5

thakx for this info guys...

ravi-kumar-123a at 2007-7-28 19:17:02 > top of Java-index,Java Essentials,Java Programming...