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

PreparedStatement.executeBatch returns unexpected values

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 3.1.4
    • N/A
    • batch
    • None

    Description

      See this test case:

      @Test
      public void test() throws SQLException {
          String url = "jdbc:mariadb://localhost:3366/test?user=user&password=password";
          Connection con = DriverManager.getConnection(url);
          Statement stmt = con.createStatement();
          stmt.execute("DROP TABLE IF EXISTS t0");
          stmt.execute("CREATE TABLE t0(c0 REAL SIGNED  PRIMARY KEY NOT NULL) engine=InnoDB");
          stmt.close();
          PreparedStatement pstmt = con.prepareStatement("INSERT INTO t0 VALUES(?)");
          for (int i = 0; i < 2; i++) {
              pstmt.setDouble(1, i);
              pstmt.addBatch();
          }
          int[] res = pstmt.executeBatch();
          for (int t : res) {
              System.out.println(t);
          }
      }
      

      I expect pstmt.executeBatch() returns 1, 1. However, Mariadb Connector J returns -2, -2.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            dwenking Wenqian Deng
            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.