String query =LOAD DATA LOCAL INFILE 'airline.csv' INTO TABLE airline_tweets1 FIELDS TERMINATED BY '`' (tweet_id BIGINT,airline_sentiment VARCHAR,airline_sentiment_confidence DOUBLE,negativereason VARCHAR,negativereason_confidence VARCHAR,airline VARCHAR,airline_sentiment_gold VARCHAR,name VARCHAR,negativereason_gold VARCHAR,retweet_count INT,text VARCHAR,tweet_coord VARCHAR,tweet_created VARCHAR,tweet_location VARCHAR,user_timezone VARCHAR);
stmt.executeUpdate(query);
当我运行上述查询时,我得到了
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:你有一个 SQL语法错误;查看与您的手册相对应的手册 MySQL服务器版本为正确的语法使用附近 'BIGINT,airline_sentiment VARCHAR,airline_sentiment_confidence 在第1行DOUBLE,negativerea'
我该如何解决这个问题?
答案 0 :(得分:0)
您没有列出LOAD DATA
查询中列的数据类型。它们仅在使用CREATE TABLE
查询创建表时使用。
String query =LOAD DATA LOCAL INFILE 'airline.csv' INTO TABLE airline_tweets1 FIELDS TERMINATED BY '`' (tweet_id, airline_sentiment, airline_sentiment_confidence, negativereason, negativereason_confidence, airline , airline_sentiment_gold, name, negativereason_gold, retweet_count, text, tweet_coord, tweet_created, tweet_location, user_timezone);