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

Inconsistency in Behavior of PreparedStatement After closeOnCompletion() Between MariaDB and MySQL Connectors

    XMLWordPrintable

Details

    Description

      In the test case, pstmt.closeOnCompletion() is called, which should set the PreparedStatement to close automatically when all its associated result sets are closed. The expectation, based on standard JDBC behavior, is that once the statement is closed (either explicitly or automatically), no further operations should be allowed on it.
      However, the MariaDB Connector's behavior deviates from this expectation, as it allows a subsequent execute() call on the closed statement, whereas the MySQL Connector J throws a java.sql.SQLException stating "No operations allowed after statement closed."

      @Test public void test() throws Exception {
          Connection con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test1551?user=user&password=password");
          PreparedStatement pstmt = con.prepareStatement("SELECT 1;");
          pstmt.execute();
          pstmt.closeOnCompletion();
          System.out.println(pstmt.getMoreResults(Statement.CLOSE_CURRENT_RESULT));
          try {
              // mysql: java.sql.SQLException: No operations allowed after statement closed.
              // mariadb: true
              System.out.println(pstmt.execute());
          } catch (Exception e) {
              System.out.println(e);
          }
      }
      

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            dwenking Wenqian Deng
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.