在sql中使用函数,遇到net.sf.jsqlparser.parser.ParseException异常

异常如下:

Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, please exclude the tableName or statementId.

Caused by: net.sf.jsqlparser.JSQLParserException: null
    at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:137)
    at com.baomidou.mybatisplus.core.parser.AbstractJsqlParser.parser(AbstractJsqlParser.java:60)
    ... 131 common frames omitted
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "<" "<"
    at line 20, column 34.

Was expecting one of:

    "&"
    ","
    "."
    "::"
    ";"
    "<<"
    ">>"
    "ACTION"
    "ANY"
    "AS"
    "BYTE"
    "CASCADE"
    "CAST"
    "CHANGE"
    "CHAR"
    "CHARACTER"
    "COLLATE"
    "COLUMN"
    "COLUMNS"
    "COMMENT"
    "COMMIT"
    "CONNECT"
    "DESCRIBE"
    "DO"
    "DUPLICATE"
    "ENABLE"
    "END"
    "EXCEPT"
    "EXTRACT"
    "FALSE"
    "FIRST"
    "FN"
    "FOLLOWING"
    "FOR"
    "FROM"
    "GROUP"
    "HAVING"
    "INDEX"
    "INSERT"
    "INTERSECT"
    "INTERVAL"
    "INTO"
    "ISNULL"
    "KEY"
    "LAST"
    "MATERIALIZED"
    "MINUS"
    "NEXTVAL"
    "NO"
    "NULLS"
    "OPEN"
    "ORDER"
    "OVER"
    "PARTITION"
    "PATH"
    "PERCENT"
    "PRECISION"
    "PRIMARY"
    "PRIOR"
    "RANGE"
    "READ"
    "REPLACE"
    "ROW"
    "ROWS"
    "SEPARATOR"
    "SESSION"
    "SIBLINGS"
    "SIZE"
    "START"
    "TABLE"
    "TEMP"
    "TEMPORARY"
    "TOP"
    "TRUE"
    "TRUNCATE"
    "TYPE"
    "UNION"
    "UNSIGNED"
    "VALUE"
    "VALUES"
    "WHERE"
    "WINDOW"
    "XML"
    "ZONE"
    "["
    "^"
    "|"
   
   
   
   
   
   
 

 

原因为:在sql语句中使用了函数,缺少sql解析工具的jar包

 

解决方案:在pom.xml文件中添加关于jsqlparser的依赖,注意必须使用0.9以上的版本,否则运行时会报错

 



    com.github.jsqlparser
    jsqlparser
    1.4

 

你可能感兴趣的:(java,mysql)