【发布时间】:2014-02-16 03:23:21
【问题描述】:
我想通过 java 程序使用 load data infile 命令将文件加载到 mysql 表中,但我收到 MySQL 语法错误:
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 '' at line 1
sql语句如下:
String sql = "LOAD DATA LOCAL INFILE '/Dataset/"+listOfFiles[i].getName()+".txt'" +
" INTO TABLE data " +
" CHARACTER SET utf8 " +
" FIELDS " +
" TERMINATED BY '|' " +
" LINES " +
" STARTING BY 'status' " +
" TERMINATED BY '\n' " +
" (@col_type, @col_origin, @col_text, @col_url, @col_id, @col_time, @col_retcount)"+
" set userid = '1234' "
" , original = @col_origin "+
" , datatext = @col_text "+
" , url = @col_url "+
" , id = @col_id "+
" , retcount = @col_retcount "+
" , date = str_to_date(@col_time, '%m/%d/%Y') "+
" , isanswer = CASE WHEN @col_origin LIKE '% abcd %' THEN 1 ELSE 0 END ";
我的问题是我无法发现错误。 谁能帮帮我?
【问题讨论】: