Results 1 to 7 of 7
Thread: Import to MySQL from a CSV file
- 03-17-2012, 12:50 PM #1
Member
- Join Date
- Feb 2012
- Location
- Norway
- Posts
- 96
- Rep Power
- 0
- 03-17-2012, 12:59 PM #2
Re: Import to MySQL from a CSV file
hi,
google first result
Import Data from Txt or CSV files into MYSQL database tables
regards
dhilip
- 03-17-2012, 03:44 PM #3
Member
- Join Date
- Feb 2012
- Location
- Norway
- Posts
- 96
- Rep Power
- 0
Re: Import to MySQL from a CSV file
Thanks!
- 03-17-2012, 03:48 PM #4
Re: Import to MySQL from a CSV file
- 03-18-2012, 11:05 AM #5
Member
- Join Date
- Feb 2012
- Location
- Norway
- Posts
- 96
- Rep Power
- 0
Re: Import to MySQL from a CSV file
I have tried this but something isn't right with my code...
.gif)
I have a textfield for input of the filepath.Java Code:String filename = textFileName.getText(); String query = "LOAD DATA INFILE '"+filename+"' INTO TABLE TestTable FIELDS TERMINATED BY ',' (FirstName,LastName,Location)";
I type C:\Temp\Test.csv in this field, but when I run the code I get an exeption:
EDIT: I changed the query to this:Java Code:java.sql.SQLException: File '/var/lib/mysql/genealogy/C:Temp est1.csv' not found (Errcode: 2)
But it still do something wrong with the path...Java Code:String query = "LOAD DATA LOCAL INFILE '"+filename+"' INTO TABLE TestTable FIELDS TERMINATED BY ',' (FirstName,LastName,Location)";
Last edited by asai; 03-18-2012 at 11:22 AM.
- 03-18-2012, 05:09 PM #6
Member
- Join Date
- Feb 2012
- Location
- Norway
- Posts
- 96
- Rep Power
- 0
Re: Import to MySQL from a CSV file
Update: I have managed to get it to work, but not 100%...
If I write the path like this: C:\\Temp\\test.csv it imports the content of the file.
I would also like to have the first row in the csv file to hold the table columnnames.
Any suggestions?
- 03-19-2012, 11:05 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
import Excel file into Mysql DB via Java unknown problem
By black300 in forum JDBCReplies: 0Last Post: 04-02-2011, 10:22 AM -
How do I import a list file?
By Codeless in forum New To JavaReplies: 1Last Post: 11-14-2010, 02:36 PM -
how to import xfdf file into the pdf file
By jkrishnanvenkat in forum New To JavaReplies: 3Last Post: 11-09-2009, 02:46 AM -
How to import file from same directory?
By Splat in forum New To JavaReplies: 5Last Post: 10-14-2009, 04:11 AM -
how to import war file with tomcat?
By makpandian in forum NetBeansReplies: 0Last Post: 12-31-2008, 11:00 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks