jsp - Csv file to MySQL database table -


fix error , need import(store) csv files mysql database table

class.forname("com.mysql.jdbc.driver");     java.sql.connection c = null;     c = drivermanager.getconnection("jdbc:mysql://localhost:3306/sample", "root", "root");     statement s = null;     s = (statement) c.createstatement();     int = s.executeupdate("load data local infile 'e:\\book1.csv' table sample.copy_table fields terminated ',' optionally enclosed '"' lines terminated '\r\n'"); 

returned errors :

error:invalid character constant in line ("load data local infile'e:\\book1.csv'.......) java.sql.sqlexception: unable open file 'e:book1.csv'for 'load data local infile' command.due underlying ioexception:   ** begin nested exception **   java.io.filenotfoundexception message: e:book1.csv (the system cannot find file specified) 

try this, forgot escape ":

int = s.executeupdate("load data local infile 'e:\\book1.csv' table sample.copy_table fields terminated ',' optionally enclosed '\"' lines terminated '\r\n'"); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -