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

Connection.getMetaData() returns MariaDbClob instead of String

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.3
    • Fix Version/s: 3.0.4
    • Component/s: metadata
    • Labels:
      None

      Description

      There's a difference between 2.7.5 and 3.0.3 / 3.0.4-SNAPSHOT, which leads to the error "ClassCastException: class [B cannot be cast to class java.lang.String" in Liquibase (see https://github.com/liquibase/liquibase/issues/2431).

      Connection.getMetaData().getColumns() returned in 2.7.5 a ResultSet, where the column type of "TYPE_NAME" was a java.lang.String. But 3.0.4 returns a org.mariadb.jdbc.MariaDbClob, which is then converted by Liquibase into a byte[] (See https://github.com/liquibase/liquibase/blob/79c0e38fe8987bdc7f4200cc05efa1b7c8276248/liquibase-core/src/main/java/liquibase/util/JdbcUtil.java#L89-L90) because MariaDbClob implements java.sql.Blob.

      Is this an error on MariaDB side or is this something, that Liquibase would need to fix?

      Please see the attached TestCase.java. If I run it with different version, I'll get the following results:

      $ java --class-path=mariadb-java-client-2.7.5.jar TestCase.java 
      Metadata: class java.lang.String
      VARCHAR col: class java.lang.String
       
      $ java --class-path=mariadb-java-client-3.0.3.jar TestCase.java 
      Metadata: class org.mariadb.jdbc.MariaDbClob
      VARCHAR col: class java.lang.String
       
      $ java --class-path=mariadb-java-client-3.0.4-SNAPSHOT.jar TestCase.java 
      Metadata: class org.mariadb.jdbc.MariaDbClob
      VARCHAR col: class java.lang.String 
      

      Real queries seem to behave the correctly and return a String for VARCHAR columns.

      This currently prevents Liquibase / Liquibase-Percona from Upgrading to MariaDB Connector 3.x (https://github.com/liquibase/liquibase-percona/pull/180).

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            adangel Andreas Dangel
            Votes:
            1 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.