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

Vendor code is not properly propagated to parent BatchUpdateException for executeBatch()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 1.1.7
    • 1.1.8
    • None
    • None

    Description

      How to reproduce:
      Run the attached VendorCodeExeceptionTest.java and especially the method testNoSuchTableBatchUpdate()
      Pseudo code:

      1. Think out a good table name
      2. Don’t create a table (drop it to make sure it does not exist)
      3. Create a PreparedStatement to insert data in the non-existing table
      4. Add a batch to PreparedStatement
      5. Execute the batch

      Actual:

      java.lang.AssertionError: expected:<1146> but was:<0>
      	at org.mariadb.jdbc.VendorCodeExeceptionTest.testNoSuchTableBatchUpdate(VendorCodeExeceptionTest.java:78)

      The vendor code is 0. In other words it is not set.

      Expected:
      The vendor code should be propagated up to the parent exception to make it easier for the program (and perhaps also to be more compatible with Mysql JDBC).

      Compare with the test case testNoSuchTable(). In this case the error could should be 1146 as described at http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html

      Analysis and suggested fix:
      The bug is in MySQLPreparedStatement.executeBatch() and the catch clause. Every parameter except the vendorCode is passed to the constructor of BatchUpdateException. My suggestion is to add the vendorCode as a parameter.

      Feel free to add my test class to the MariaDB source code.

      Attachments

        Activity

          People

            massimo.siani Massimo Siani (Inactive)
            lennartschedin Lennart Schedin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.