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

Permit executeQuery commands to not return a resultset

Details

    Description

      Here's a clearer explanation of query execution methods and proposed changes:
      Statement/PreparedStatement offers three execution methods:

      • execute(): Handles any SQL statement type, returns boolean indicating if result is a ResultSet
      • executeUpdate(): For DML (INSERT/UPDATE/DELETE) and DDL statements that don't return data. Returns update count.
      • executeQuery(): For SELECT and other queries returning data. Currently requires ResultSet return, throwing exception if none exists.

      Proposed Change:
      When executeQuery() executes a command producing no ResultSet, return empty ResultSet instead of throwing exception. This improves backward compatibility and user experience. An option will permit strict JDBC compliance but disabled by default.

      Implementation Note:
      Unlike MySQL Connector/J, we won't parse queries to pre-validate ResultSet production, as this creates unnecessary performance overhead

      Attachments

        Activity

          diego dupin Diego Dupin added a comment - - edited

          option `permitNoResults` control this behavior :

          permitNoResults default to true, permitting executeQuery with no resultset.
          example:

          try (Connection con = DriverManager.getConnection("jdbc:mariadb://localhost/db", "user", "pwd")) {
                Statement stmt = con.createStatement();
                stmt.executeQuery("DO 1");
          }
          

          works without issue.

          while disabling option `permitNoResults`, executeQuery command that returns no resultset will throw an exception

          try (Connection con = DriverManager("jdbc:mariadb://localhost/db?permitNoResults=false", "user", "pwd")) {
                Statement stmt = con.createStatement();
                stmt.executeQuery("DO 1");  // will thrown exception "Statement.executeQuery() command does NOT return a result-set as expected ..."
          }
          

          diego dupin Diego Dupin added a comment - - edited option `permitNoResults` control this behavior : permitNoResults default to true, permitting executeQuery with no resultset. example: try (Connection con = DriverManager.getConnection( "jdbc:mariadb://localhost/db" , "user" , "pwd" )) { Statement stmt = con.createStatement(); stmt.executeQuery( "DO 1" ); } works without issue. while disabling option `permitNoResults`, executeQuery command that returns no resultset will throw an exception try (Connection con = DriverManager( "jdbc:mariadb://localhost/db?permitNoResults=false" , "user" , "pwd" )) { Statement stmt = con.createStatement(); stmt.executeQuery( "DO 1" ); // will thrown exception "Statement.executeQuery() command does NOT return a result-set as expected ..." }

          People

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