Bug #78099 preparedStatement.executeBatch() return -2.
Submitted: 17 Aug 2015 6:42 Modified: 17 Aug 2015 7:53
Reporter: Tatsuhiko Suzuki Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.36 OS:Any
Assigned to: CPU Architecture:Any
Tags: batch, insert

[17 Aug 2015 6:42] Tatsuhiko Suzuki
Description:
Hi.

preparedStatement.executeBatch() return -2
when insert 2 or more lines and rewriteBatchedStatements=true.

How to repeat:
sample code
--------------------------------------------------------------
int[] r = new int[] {};
Connection conn = DriverManager.getConnection(
        "jdbc:mysql://localhost:3306/schema"
                + "?rewriteBatchedStatements=true", "user", "pass");
PreparedStatement pstmt = conn
        .prepareStatement(
                "insert into table1 (col1, col2) values (?, 'test'");
pstmt.clearBatch();
for (int i = 0; i < 2; i++) {
    pstmt.setString(1, "A" + i);
    pstmt.addBatch();
}
r = pstmt.executeBatch();
--------------------------------------------------------------

Expected result:
  return [1,1]  or  [2]

Actual result:
  return [-2,-2]

My Environment:
    Windows 7 x64
    JDK 1.8.0_40 (x64)
    MySQL Connector/J 5.1.36
    MySQL Server 5.7.7-rc

Suggested fix:
None.
[17 Aug 2015 6:44] Tatsuhiko Suzuki
update tags.
[17 Aug 2015 7:53] Tatsuhiko Suzuki
sorry. This wouldn't be a bug.