Java Util SQL 解析器为正确语句抛出异常
Java Util SQL Parser throws an exception for a correct statement
我的说法是
new_call.cdctype=goal.cdctype
当我对此调用方法 CCJSqlParser.SQLCondition() 时,出现异常提示
Encountered " "=" "= "" at line 1, column 17.
Was expecting one of:
"NOT" ...
"LIKE" ...
"ILIKE" ...
"NOT" ...
"NOT" ...
知道为什么会这样吗?
我正在检查连接条件,我认为这是连接条件的合适表达式。
代码:
String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringReader(sql));
String errorMsg=null;
try {
parser.SQLCondition();
} catch (ParseException e) {
errorMsg=e.getMessage();
}
return errorMsg;
如果您更深入地研究 JSqlParsers 语法,您会发现,SQLCondition 只是其中之一:
- 在
- 之间
- 为空
- 存在
- 喜欢
表达式。
您指定了所谓的 RegularCondition。
这里有两种方法来解析你的条件:
//Shortcut
Expression parseCondExpression = CCJSqlParserUtil.parseCondExpression("new_call.cdctype=goal.cdctype");
System.out.println(parseCondExpression);
//from issue
String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sql));
try {
parser.RegularCondition();
} catch (ParseException e) {
e.printStackTrace();
}
顺便说一句,我正在使用 JSqlParser V1.2。您的版本似乎有点旧,因为解析器的构造函数参数现在是 Provider.
我的说法是
new_call.cdctype=goal.cdctype
当我对此调用方法 CCJSqlParser.SQLCondition() 时,出现异常提示
Encountered " "=" "= "" at line 1, column 17.
Was expecting one of:
"NOT" ...
"LIKE" ...
"ILIKE" ...
"NOT" ...
"NOT" ...
知道为什么会这样吗? 我正在检查连接条件,我认为这是连接条件的合适表达式。
代码:
String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringReader(sql));
String errorMsg=null;
try {
parser.SQLCondition();
} catch (ParseException e) {
errorMsg=e.getMessage();
}
return errorMsg;
如果您更深入地研究 JSqlParsers 语法,您会发现,SQLCondition 只是其中之一:
- 在
- 之间
- 为空
- 存在
- 喜欢 表达式。
您指定了所谓的 RegularCondition。
这里有两种方法来解析你的条件:
//Shortcut
Expression parseCondExpression = CCJSqlParserUtil.parseCondExpression("new_call.cdctype=goal.cdctype");
System.out.println(parseCondExpression);
//from issue
String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sql));
try {
parser.RegularCondition();
} catch (ParseException e) {
e.printStackTrace();
}
顺便说一句,我正在使用 JSqlParser V1.2。您的版本似乎有点旧,因为解析器的构造函数参数现在是 Provider.