我的 SQL 查询中没有任何“est”。我可以使用这个SQL直接成功插入vertica,但是当我使用JDBC时就出错了。
java.sql.SQLException: [Vertica]VJDBC ERROR: Syntax error at or near "est" [ insert into .... ]
Caused by: java.sql.SQLException: [Vertica]VJDBC ERROR: Syntax error at or near "est" at com.vertica.util.ServerErrorData.buildException(Unknown Source) at com.vertica.dataengine.VDataEngine.prepareImpl(Unknown Source) at com.vertica.dataengine.VDataEngine.prepareBatch(Unknown Source) at com.vertica.dataengine.VDataEngine.prepareBatch(Unknown Source) at com.vertica.jdbc.SStatement.executeBatch(Unknown Source) at com.lina.common.util.JdbcConn.executeBatchUpdate(JdbcConn.java:77)
整个查询的错误:
java.sql.SQLException: [Vertica]VJDBC ERROR: Syntax error at or near "est" [ insert into public.gamelive_original(hour, minute, ip, country, sp, act, time, uid, pcode, r_name, r_owner, r_owne_id, r_category, online_num, ver,sender,msg,dt) values ( '21','40','125.90.93.219','hello',NULL,'webzb',NULL,'10240','hello','hello','hello',NULL,'hello','6094',NULL,'yeschenshu','love','2016-01-17' ) ]
最佳答案
您的堆栈跟踪表明批量更新 - 错误将出现在更新的行之一中。
由于您的日志显示 SQL 内部的参数,您可能没有使用 PreparedStatement
我最好的猜测:你的代码中缺少转义并插入一个像...这样的字符串
"C'est la vie"
如果没有正确的转义,将会创建一个类似的 Sql
insert into foo(bar) values('C'est la vie')
这会在“est”附近产生错误
关于java - Vertica JDBC错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34896462/