@SqlQuery抛出org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException:java.sql.SQLException:SQL Anywhere错误-131

时间:2016-02-15 13:18:46

标签: java sybase-iq

执行时:

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'

当我删除此set.seed(1234) y <- 1e7 renamer <- function(text){ text[grep("ac", text)] <- "aaa" text[grep("gf", text)] <- "bbb" text[grep("er", text)] <- "ccc" text[grep("hy", text)] <- "ddd" text[grep("nh", text)] <- "eee" text[grep("oi", text)] <- "fff" text[grep("nu", text)] <- "ggg" text[grep("vf", text)] <- "hhh" text[grep("cd", text)] <- "iii" text[grep("po", text)] <- "jjj" return(text) } smp <- NULL for(i in 1:100){ smp <- c(smp, paste0(sample(letters, 15, T), collapse= "")) } df <- data.table(a = sample(smp, y, T)) # > system.time(renamer(text = df$a)) # user system elapsed # 15.54 0.08 15.70 时,查询工作正常。是&lt;问题的原因?

1 个答案:

答案 0 :(得分:4)

这个问题可以归结为:

  • 将antlr与jdbi混合,antlr负责对sql语句进行分块。 Jdbi声称它可以在没有任何依赖性的情况下运行,因此不需要antlr jar我认为只有jdbi包就足够了
  • 或者它可能是一个bug,因为我在解析jdbi中的sql语句时发现了一些问题来解决这个问题,你可以逃避&lt;与\一样 \\&lt;