[CONJ-287] Invalid query generated on prepared statement Created: 2016-04-23  Updated: 2016-04-25  Resolved: 2016-04-25

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.3.7, 1.4.2
Fix Version/s: 1.4.3

Type: Bug Priority: Major
Reporter: Bart Laarhoven Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates CONJ-283 MariaDbClientPreparedStatement - synt... Closed
Relates
relates to CONJ-277 Incorrect error when dealing with typ... Closed

 Description   

This is my first issue here, so if I forgot to add some information, just ask
I've tested the following with 1.3.7 and 1.4.2. On 1.3.6, the behaviour is correct.

I have a prepared statement as follows:

INSERT INTO  `tableX`  (`textA`, `dateB`, `textC`, `longD`, `tinyintE`) VALUES  (?, ?, ?, ?, ?) ,  (?, ?, ?, ?, ?) ,  (?, ?, ?, ?, ?) ,  (?, ?, ?, ?, ?)

And I add the following parameters (with the Java classes between parentheses):

150 (String), 2016-04-23 16:40:20.804 (Timestamp), 1:142:14895 (String), 5528 (Long), 0 (Integer), 
null, 2016-04-23 16:40:20.804 (Timestamp), 1:102:1712 (String), 5528 (Long), 0 (Integer), 
null, 2016-04-23 16:40:20.804 (Timestamp), 1:102:1159 (String), 5528 (Long), 0 (Integer), 
[] (String), 2016-04-23 16:40:20.804 (Timestamp), 1:142:4142 (String), 5528 (Long), 0 (Integer)

Nevertheless, I get the following error (in v1.4.2):

org.mariadb.jdbc.internal.util.dao.QueryException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL ,  ('2016-04-23 16:40:20.804', '1:102:1712', 5528, 0, NULL) ,  ('2016-04-23' at line 1
Query is : INSERT INTO  `tableX`  (`textA`, `dateB`, `textC`, `longD`, `tinyintE`) VALUES ('150', '2016-04-23 16:40:20.804', '1:142:14895', 5528, 0)<null> ,  ('2016-04-23 16:40:20.804', '1:102:1712', 5528, 0, <null>) ,  ('2016-04-23 16:40:20.804', '1:102:1159', 5528, 0, '[]') ,  ('2016-04-23 16:40:20.804', '1:142:4142', 5528, 0, )
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:870)
                at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQueries(AbstractQueryProtocol.java:789)
                at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:498)
                at org.mariadb.jdbc.internal.failover.AbstractMastersListener.invoke(AbstractMastersListener.java:314)
                at org.mariadb.jdbc.internal.failover.FailoverProxy.invoke(FailoverProxy.java:155)
                at com.sun.proxy.$Proxy22.executeQueries(Unknown Source)
                at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternal(MariaDbClientPreparedStatement.java:177)

I can't completely figure out why (maybe the null value?) but my initial prepared statement gets changed into an invalid one. As I said, I have encountered this error with Connector/J versions 1.3.7 and 1.4.2 in (as it seems) all queries that use this multiple INSERT syntax. In version 1.3.6 it works as it should.

I hope you can fix this, because this is preventing me from upgrading to the latest version.



 Comments   
Comment by Bart Laarhoven [ 2016-04-23 ]

Same syntax behavior in CONJ-277

Comment by Diego Dupin [ 2016-04-25 ]

solved in 1.4.3. see CONJ-283

Generated at Thu Feb 08 03:14:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.