我们需要将客户提供的CSV文件中的数据加载到MySQL表中。我们正在使用以下代码。
LOAD DATA INFILE 'C:/Users/chan/Desktop/gradeschool-student-sorting-app/Output/conertedCSV.csv' INTO TABLE student_temp FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES;
手动加载时,工作正常。但是在通过java执行上述操作时,它会抛出一些例外。
Query: LOAD DATA INFILE C:/Users/chan/Desktop/gradeschool-student-sorting-app/Output/conertedCSV.csv INTO TABLE student_temp FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES; Connection successful You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'C:/Users/s521753/Desktop/gradeschool-student-sorting-app/Output/conertedCSV.csv' at line 1 Executed query successfully