Lina
Lina

Reputation: 21

Vertica JDBC wrong

My SQL Query doesn't have any "est" in it. I can use this SQL successfully insert into vertica directly, but it goes wrong when I use 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)

The error with the entire query:

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','hel‌​lo',NULL,'hello','6094',NULL,'yeschenshu','love','2016-01-17' ) ]

Upvotes: 0

Views: 2076

Answers (1)

Jan
Jan

Reputation: 13858

Your stacktrace indicates a batched update - error will be in one of the updated rows.

As your log shows parameters inside SQL you probably didn't use PreparedStatement

My best guess: you have missing escaping in your code and insert a string like...

  "C'est la vie"

Which without proper escaping will create a Sql like

  insert into foo(bar) values('C'est la vie')

Which would create an error near "est"

Upvotes: 4

Related Questions