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

Internal cast exception in DatabaseMetaData.executeQuery()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 3.3.1
    • 3.3.2
    • metadata
    • None

    Description

      This bug was introduced in 3.3.1 (works fine in 3.3.0):

      org.mariadb.jdbc.DatabaseMetaData.executeQuery.DatabaseMetaData.java()
      private ResultSet executeQuery(String sql) throws SQLException {
      Statement stmt =
      connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
      CompleteResult rs = (CompleteResult) stmt.executeQuery(sql);
      rs.setStatement(null); // bypass Hibernate statement tracking (CONJ-49)
      rs.useAliasAsName();
      return rs;
      }
      

      Here the cast to CompleResult throws an exception since it gots a StreamingResult!

      Exception thrown:

      2023-12-11 09:05:59 - java.lang.ClassCastException: class org.mariadb.jdbc.client.result.StreamingResult cannot be cast to class org.mariadb.jdbc.client.result.CompleteResult (org.mariadb.jdbc.client.result.StreamingResult and org.mariadb.jdbc.client.result.CompleteResult are in unnamed module of loader 'app')
      2023-12-11 09:06:00 -     at org.mariadb.jdbc.DatabaseMetaData.executeQuery(DatabaseMetaData.java:557)
      2023-12-11 09:06:00 -     at org.mariadb.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:771)
      

      We use parameters "useCursorFetch=true;defaultFetchSize=1000" in the JDBC connection string.
      The code triggering this (running inside Wildfly 30):

             try (ResultSet rs = connection.getMetaData().getTables(connection.getCatalog(), connection.getSchema(), "sn_dbversion", new String[] { "TABLE" }))
              {
                  while (rs.next())
                  ...
      

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            Heuler Marius
            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.