当我执行时:
@SqlQuery("select A.field1, A.field2, C.field3, C.field4, C.field5 from "
+ "table1 A, table2 B, table3 C WHERE A.field2 >= '1500' AND A.field2 < '9500' "
+ "AND A.field1 NOT IN (SELECT field1 FROM table4) AND A.field1 = B.field1 AND "
+ "(B.field3 = 'NAME' OR B.field3 ='STRT') order by A.field1 ASC")
我继续出现以下错误:
problem parsing template 'c2VsZWN0IEEuVVBDX05VTSwgQS5NT0RVTEVfTlVNLCBDLkNIUl9OTSwgQy5DSFJfQ0QsIEMuVkwgZnJvbSBVUEMgQSwgVVBDX0NIUiBCLCBDSFJfVkwgQyBXSEVSRSBBLk1PRFVMRV9OVU0gPj0gJzEwMDAnIEFORCBBLk1PRFVMRV9OVU0gPCAnOTAwMCcgQU5EIEEuVVBDX05VTSBOT1QgSU4gKFNFTEVDVCBVUENfTlVNIEZST00gVVBDX0FDVFYpIEFORCBBLlVQQ19OVU0gPSBCLlVQQ19OVU0gIEFORCAoQi5DSFJfTk0gPSAnQlJBTkQnIE9SIEIuQ0hSX05NID0nVFlQRScpIEFORCBCLk1PRFVMRV9OVU0gPSBDLk1PRFVMRV9OVU0gIEFORCBCLkNIUl9OTSA9IEMuQ0hSX05NICBBTkQgQi5DSFJfQ0QgPSBDLkNIUl9DRCBvcmRlciBieSBBLlVQQ19OVU0gQVND'
line 1:373: expecting '>', found '<EOF>'
at org.antlr.stringtemplate.language.AngleBracketTemplateLexer.nextToken(AngleBracketTemplateLexer.java:149)
at antlr.TokenBuffer.fill(TokenBuffer.java:69)
at antlr.TokenBuffer.LA(TokenBuffer.java:80)
at antlr.LLkParser.LA(LLkParser.java:52)
at org.antlr.stringtemplate.language.TemplateParser.template(TemplateParser.java:103)
at org.antlr.stringtemplate.StringTemplate.breakTemplateIntoChunks(StringTemplate.java:850)
at org.antlr.stringtemplate.StringTemplate.setTemplate(StringTemplate.java:441)
at org.antlr.stringtemplate.StringTemplateGroup.defineTemplate(StringTemplateGroup.java:679)
at org.skife.jdbi.v2.sqlobject.stringtemplate.StringTemplate3StatementLocator.locate(StringTemplate3StatementLocator.java:260)
at org.skife.jdbi.v2.SQLStatement.wrapLookup(SQLStatement.java:1284)
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1293)
at org.skife.jdbi.v2.Query.iterator(Query.java:240)
at org.skife.jdbi.v2.sqlobject.ResultReturnThing$IteratorResultReturnThing.result(ResultReturnThing.java:162)
at org.skife.jdbi.v2.sqlobject.ResultReturnThing.map(ResultReturnThing.java:43)
at org.skife.jdbi.v2.sqlobject.QueryHandler.invoke(QueryHandler.java:43)
at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:212)
at org.skife.jdbi.v2.sqlobject.SqlObject$2.intercept(SqlObject.java:109)
at com.test.project.MyDAO$$EnhancerByCGLIB$$96e97b19.usTest(<generated>)
at com.test.project.Main.getDataDb(Main.java:300)
at com.test.project.Main.run(Main.java:130)
at com.test.project.Main.main(Main.java:83)
Exception in thread "main" org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.SQLException: SQL Anywhere Error -131: Syntax error near '(end of line)' on line 1 [statement:"select A.field1, A.field2, C.field3, C.field4, C.field5 from table1 A, table2 B, table3 C WHERE A.field2 >= '1500' AND A.field2 < '9500' AND A.field1 NOT IN (SELECT field1 FROM table4) AND A.field1 = B.field1 AND (B.field3 = 'NAME' OR B.field3 ='STRT') order by A.field1 ASC", located:"select A.field1, A.field2, C.field3, C.field4, C.field5 from table1 A, table2 B, table3 C WHERE A.field2 >= '1500' AND A.field2 < ", arguments:{ positional:{}, named:{}, finder:[]}]
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1337)
at org.skife.jdbi.v2.Query.iterator(Query.java:240)
at org.skife.jdbi.v2.sqlobject.ResultReturnThing$IteratorResultReturnThing.result(ResultReturnThing.java:162)
at org.skife.jdbi.v2.sqlobject.ResultReturnThing.map(ResultReturnThing.java:43)
at org.skife.jdbi.v2.sqlobject.QueryHandler.invoke(QueryHandler.java:43)
at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:212)
at org.skife.jdbi.v2.sqlobject.SqlObject$2.intercept(SqlObject.java:109)
at com.test.project.MyDAO$$EnhancerByCGLIB$$96e97b19.usTest(<generated>)
at com.test.project.Main.getDataDb(Main.java:300)
at com.test.project.Main.run(Main.java:130)
at com.test.project.Main.main(Main.java:83)
Caused by: java.sql.SQLException: SQL Anywhere Error -131: Syntax error near '(end of line)' on line 1
at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.handleSQLE(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.executeLoop(Unknown Source)
at com.sybase.jdbc4.jdbc.SybStatement.execute(Unknown Source)
at com.sybase.jdbc4.jdbc.SybPreparedStatement.execute(Unknown Source)
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1326)
... 10 more
当我删除此
A.field2 < '9500'
时,查询工作正常。是 最佳答案
该问题可能来自以下任一方面:
将antlr与jdbi混合使用,antlr负责分块sql语句。 Jdbi声称它可以在没有任何依赖的情况下运行,因此不需要antlr jars,我认为只有jdbi包就足够了
或它可能是一个错误,因为我在解析jdbi中的sql语句时发现了一些问题,以解决此问题,您可以使用这样的\
关于java - @SqlQuery抛出org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException:java.sql.SQLException:SQL Anywhere错误-131,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35410426/