执行代码如下
SQLUtils.parseStatements(ddl, “mysql”);
报错如下
com.alibaba.druid.sql.parser.ParserException: unclosed str. pos 272, line 5, column 62, token COMMENT
at com.alibaba.druid.sql.parser.Lexer.scanString2(Lexer.java:1111) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlLexer.scanString(MySqlLexer.java:416) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.parser.Lexer.nextToken(Lexer.java:735) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.parser.SQLExprParser.parseColumnRest(SQLExprParser.java:2883) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.parseColumnRest(MySqlExprParser.java:620) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.parser.SQLExprParser.parseColumnRest(SQLExprParser.java:2770) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.parseColumnRest(MySqlExprParser.java:620) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.parseColumn(MySqlExprParser.java:542) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlCreateTableParser.parseCreateTable(MySqlCreateTableParser.java:232) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseCreate(MySqlStatementParser.java:414) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:260) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:171) ~[druid-1.1.14.jar:1.1.14]
at com.alibaba.druid.sql.SQLUtils.parseStatements(SQLUtils.java:495) ~[druid-1.1.14.jar:1.1.14]
表结构如下
CREATE TABLE `price_honest` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`sku_id` bigint(20) NOT NULL COMMENT '商品id',
`promo_up_price_day_num_up` int(11) DEFAULT NULL COMMENT '促销提价天数>10%',
`promo_up_price_day_num_down` int(11) DEFAULT NULL COMMENT '0%<促销提价天数<10%',
`operated_time` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
2条答案
按热度按时间olhwl3o21#
什么版本?
polhcujo2#
执行代码如下
报错如下
表结构如下
用master版本测试是可以的,你估计是SQL语句少了个'结束符
@test
public void test() {
String str = "CREATE TABLE
price_honest
(\n" +"
id
bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键',\n" +"
sku_id
bigint(20) NOT NULL COMMENT '商品id',\n" +"
promo_up_price_day_num_up
int(11) DEFAULT NULL COMMENT '促销提价天数>10%',\n" +"
promo_up_price_day_num_down
int(11) DEFAULT NULL COMMENT '0%<促销提价天数<10%',\n" +"
operated_time
datetime NOT NULL COMMENT '更新时间',\n" +" PRIMARY KEY (
id
)\n" +") ENGINE=InnoDB DEFAULT CHARSET=utf8";