Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-287

Invalid query generated on prepared statement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.7, 1.4.2
    • Fix Version/s: 1.4.3
    • Component/s: Other
    • Labels:
      None

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              diego dupin Diego Dupin
              Reporter:
              bartlaarhoven Bart Laarhoven
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: