druid lexer parse sql exception

qvsjd97n  于 2022-10-21  发布在  Druid
关注(0)|答案(1)|浏览(226)

druid lexer解析如下sql语句时出错:
select * from test where id='1' WAITFOR DELAY '0:0:5'--'
该语句在mysql中可正常执行

exception信息:
Exception in thread "main" com.alibaba.druid.sql.parser.ParserException: syntax error at end of input.
at com.alibaba.druid.sql.parser.Lexer.scanSingleLineComment(Lexer.java:863)
at com.alibaba.druid.sql.parser.Lexer.scanComment(Lexer.java:790)
at com.alibaba.druid.sql.parser.Lexer.nextToken(Lexer.java:451)

解析代码如下:
Lexer lexer = new Lexer(sql);
for (;;) {
lexer.nextToken();
Token tok = lexer.token();
......
}

相关问题