Hi guys,
I have got a question regarding LOAD DATA INFILE. Can some one save my day.
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 already exists
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.
10 4207
Hi guys,
I have got a question regarding LOAD DATA INFILE. Can some one save my day.
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 already exists
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.
hi dude try this code
try {
Connection con = // getConnection here
// Create the statement
Statement stmt = con.createStatement();
String tablename = "IMPORT";
String filename = "D:\\\\Sen.txt";
String query = "LOAD DATA INFILE \"" + filename + "\" INTO TABLE " + tablename;
stmt.executeUpdate(query);
} catch (Exception e) {
}
Hi guys,
I have got a question regarding LOAD DATA INFILE. Can some one save my day.
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 already exists
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.
Must be some directory thing. I've never used it in Java myself. A quick check here shows that you have it right for running from mysql prompt. Java looks for the file starting in the current directory where your code is but mysql looks for the file from the database directory... Still trying to fihure out what would work there if you get it please post and tell us as well.
Must be some directory thing. I've never used it in Java myself. A quick check here shows that you have it right for running from mysql prompt. Java looks for the file starting in the current directory where your code is but mysql looks for the file from the database directory... Still trying to fihure out what would work there if you get it please post and tell us as well.
Hey another one things...
But when i tried the filename = "C:/test.txt"
itz import the data from the database and load it to the text file perfectly..
but whatz special in this is.... there is no test.txt file in the C:/
Actually test.txt file is a created file by using Query
SELECT * INTO OUTFILE in the java program for export data to a file(C:/test.txt)..
When i run the above program...
there is no test.txt file in the C:/....
But when i tried to run the program again... its throwing exception
that C:/test.txt file is already exist... But there is no test.txt file..
i dont know what is happening here...
What to do for it...
plzz explain me....
Hey another one things...
But when i tried the filename = "C:/test.txt"
itz import the data from the database and load it to the text file perfectly..
but whatz special in this is.... there is no test.txt file in the C:/
Actually test.txt file is a created file by using Query
SELECT * INTO OUTFILE in the java program for export data to a file(C:/test.txt)..
When i run the above program...
there is no test.txt file in the C:/....
But when i tried to run the program again... its throwing exception
that C:/test.txt file is already exist... But there is no test.txt file..
i dont know what is happening here...
What to do for it...
plzz explain me....
When you run it first time it creates the file right?
When you run it second time, do you delete that file first?
When you run it first time it creates the file right?
When you run it second time, do you delete that file first?
Ya it is creating a file..... But it is not storing in c:/
i dont know where it is storing......
the file is storing in some other location...
the file is in invisible mode....
Ya it is creating a file..... But it is not storing in c:/
i dont know where it is storing......
the file is storing in some other location...
the file is in invisible mode....
Let us eliminate all the other possibilities first. - } catch (Exception e) {
-
}
is not handling any exception. Change it to - } catch (Exception e) {
-
-
e.printStackTace();
-
-
-
}
-
-
and run it to make sure the program is not throwing any exceptions
Now also the same result....
i will explain u clearly..
When i want a export data from a database into a text file..
i used the query, SELECT * INTO OUTFILE 'C:/test.txt' FROM TABLE....
there is no test.txt file in C:/..i cant see it...
But when i run the program again, it throwing an exception that
C:/test.txt already exists....
thats what, i came to the conclusion that, the above query creating a file
and exporting the data into that file... but i think that created file is in
invisible mode...
Now i'm trying to importing data from database from a file...
in this i had used the following query...
stmt.executeUpdate("LOAD DATA INFILE \"" + 'C:/test.txt' + "\" INTO TABLE " + tablename + " FIELDS TERMINATED BY ','");
its working perfectly running.... and importing the data from the test.txt file into
the database...
But whats special in this is.... there is no test.txt file in C:/
Can u understand what i'm saying?
Plzz tell me a solution for this....
thanks for replying...
senthil.
Now also the same result....
i will explain u clearly..
When i want a export data from a database into a text file..
i used the query, SELECT * INTO OUTFILE \'C:/test.txt\' FROM TABLE....
there is no test.txt file in C:/..i cant see it...
But when i run the program again, it throwing an exception that
C:/test.txt already exists....
thats what, i came to the conclusion that, the above query creating a file
and exporting the data into that file... but i think that created file is in
invisible mode...
Now i\'m trying to importing data from database from a file...
in this i had used the following query...
stmt.executeUpdate(\"LOAD DATA INFILE \\\"\" + \'C:/test.txt\' + \"\\\" INTO TABLE \" + tablename + \" FIELDS TERMINATED BY \',\'\");
its working perfectly running.... and importing the data from the test.txt file into
the database...
But whats special in this is.... there is no test.txt file in C:/
Can u understand what i\'m saying?
Plzz tell me a solution for this....
thanks for replying...
senthil.
Maybe some blocking as explained here..Wait a minute. I think this is taking the shape of a mysql problem so let me copy your post there as well so you can be able to view replies posted from there and here as well.
Maybe some blocking as explained here..Wait a minute. I think this is taking the shape of a mysql problem so let me copy your post there as well so you can be able to view replies posted from there and here as well.
yeaaaaahhhhhhhhhhhhhh........
Hai r035198x....
i found the solution for that....
just we have add a LOCAL keyword in the query like this
stmt.executeUpdate("LOAD DATA LOCAL INFILE \"" + filename + "\" INTO TABLE " + tablename + " FIELDS TERMINATED BY ','");
Now itz perfectly working...
Thanks for replying...
senthil
yeaaaaahhhhhhhhhhhhhh........
Hai r035198x....
i found the solution for that....
just we have add a LOCAL keyword in the query like this
stmt.executeUpdate(\"LOAD DATA LOCAL INFILE \\\"\" + filename + \"\\\" INTO TABLE \" + tablename + \" FIELDS TERMINATED BY \',\'\");
Now itz perfectly working...
Thanks for replying...
senthil
Thanks for that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bruce A. Julseth |
last post by:
When I execute this SQL statement in my PHP code, I get an error
"File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\"...
|
by: Montagna, Dan |
last post by:
------_=_NextPart_001_01C35B55.62B4A6E0
Content-Type: text/plain;
charset="iso-8859-1"
Hello,
I'm a very new mysql/php user and am trying to use the load data infile
command without luck. I'd...
|
by: Donald Tyler |
last post by:
Then the only way you can do it that I can think of is to write a PHP script
to do basically what PHPMyAdmin is trying to do but without the LOCAL in
there.
However to do that you would need to...
|
by: Alex Hunsley |
last post by:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data
infile' to put some data into a mysql database (I'm using the xampp
bundle)..
My problem is that I have a four line CSV file...
|
by: stefaan.lhermitte |
last post by:
Dear mysql-ians,
I am using mysql 5.0 and I want to load a huge txt-file in my database.
My text file (file.txt) looks like:
col1 col2 col3 ... col200
col1 col2 col3 ... col200
....
col1...
|
by: Justin |
last post by:
Hi, im facing a problem here. First of all here is my program
requirement. I got a .csv file with thousands of records inside, i need
to import them into my mysql database. So i tried using load...
|
by: seshu |
last post by:
Hi Everybody
this is seshu here i have doubt
I have a piece of code to insert data into table which is there in a txt file
and this is the code
LOAD DATA INFILE...
|
by: asenthil |
last post by:
Hi guys,
I have got a question regarding LOAD DATA INFILE. Can some one save my day.
1. I want to import a txt file into mysql database.
when I use the following query in the mysql> prompt its...
|
by: lanesbalik |
last post by:
hi all,
right now i'm trying to migrate from db2 running under linux to mysql v5.1.
i manage to export out the db2 structure & data into a del (ascii) file.
but when i try to load the data...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |