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

MariaDB JDBC Driver getHoldability() Returns Non-Standard Default Value

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      While this may not be a bug, there may be compatibility issues !!!! More serious cases may lead to unsafe realizations in the production process.

      When calling Connection.getHoldability() using the official MariaDB JDBC driver (mariadb-java-client), the method returns:
      ResultSet.HOLD_CURSORS_OVER_COMMIT // (int value: 1)
      However, according to the JDBC specification, the default holdability of a connection should be:
      ResultSet.CLOSE_CURSORS_AT_COMMIT // (int value: 2)

      This deviates from the behavior of most mainstream JDBC drivers such as MySQL, OceanBase, and Oracle, and can cause compatibility issues in applications expecting the conventional default behavior.
      *****************************************************************

      MYSQL Connector:
      <dependency>
      <groupId>com.mysql</groupId>
      <artifactId>mysql-connector-j</artifactId>
      <version>9.2.0</version>
      </dependency>
      -----------------------------------------------------------------
      MariaDB Connector:
      <dependency>
      <groupId>org.mariadb.jdbc</groupId>
      <artifactId>mariadb-java-client</artifactId>
      <version>3.5.3</version>
      </dependency>
      -----------------------------------------------------------------
      -------------------javaCode----------------------------------
      import java.sql.*;

      public class TestMysql {
      public static void main(String[] args) throws SQLException {
      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;
      PreparedStatement pstmt = null;

      con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb0?user=root&password=1234");
      stmt = con.createStatement(1003, 1007, 1);

      con.setSavepoint("savepoint1");
      try

      { con.commit(); }

      catch (Exception e)

      { System.out.println(e); }
      try { con.rollback(con.setSavepoint("savepoint2")); } catch (Exception e) { System.out.println(e); }

      System.out.println(con.isReadOnly());
      System.out.println(con.getHoldability()); // 2
      stmt.close();
      pstmt.clearParameters();
      pstmt.close();
      rs.close();
      con.close();

      }
      }

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            Ce Lyu Ce Lyu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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