LOAD DATA INFILE problem....
Hi guys,
I have got a question regarding LOAD DATA INFILE.
1. I want to import a txt file into mysql database.
when I use the following query in the mysql> prompt its fine.
which is
when I do it java I am getting error
Error
-----------
java.sql.sqlException: General error message from server:
"File 'D:/Sen.txt' not found <ErrCode: 2>"
But the file exists
Code:
Code:
try {
con = DriverManager.getConnection(url, "root", "");
stmt = con.createStatement();
stmt.executeUpdate(createString);
String filename = "D:/Sen.txt";
String tablename = "IMPORT";
stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE " + tablename + " FIELDS TERMINATED BY ','");
stmt.close();
con.close();
}
My text file(Sen.txt) is like this...
abc,1
bcd,2
adf,3
I dont know why its say like that
Can anyone help me out in this...
thanks...
senthil.
Re: LOAD DATA INFILE problem....
Is the URL to localhost? LOAD DATA INFILE reads from the computer where MySQL is running.
Does the DB have access rights to the file?
Re: LOAD DATA INFILE problem....
Hai CornedBee..
thanks for ur reply..
i already found the solution..
i just put a LOCAL keyword in the query like this
LOAD DATA LOCAL INFILE \"" + filename + "\" INTO TABLE " + tablename + " ...
Now itzz perfectly working...
thanks for ur reply..
senthil