|
-
Feb 13th, 2007, 01:44 AM
#1
Thread Starter
Junior Member
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.
-
Feb 13th, 2007, 06:22 AM
#2
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?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 13th, 2007, 06:30 AM
#3
Thread Starter
Junior Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|