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

java.lang.ClassCastException: [B cannot be cast to java.lang.String

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.5.5, 1.5.7
    • 1.5.8
    • Other
    • None
    • JDK 1.8.0.25
      Windows Server 2012
      MariaDB 10.1.19
      JPA 2.1.0

    Description

      We have a stored procedure called by Java using JPA:
      StoredProcedureQuery storedProcedure = em.createStoredProcedureQuery(EXPORT_PROCEDURE_NAME);
      storedProcedure.registerStoredProcedureParameter(OUTPUT_ATTRIBUT_NAME, String.class, ParameterMode.OUT);
      storedProcedure.execute();
      String jsonResult = (String) storedProcedure.getOutputParameterValue(OUTPUT_ATTRIBUT_NAME);

      The last line raises an error:
      java.lang.ClassCastException: [B cannot be cast to java.lang.String.
      The output of our stored procedure is a string containing JSON formatted data looking like this: [

      {param1: info1, param2: info2}

      ]
      Here is the header of the "show create procedure" query:
      STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`xxxx`@`localhost` PROCEDURE `EXPORT_TRANSFER_ALL`(OUT json_result TEXT)

      This error seems similar is similar to the one reported here: https://mariadb.atlassian.net/browse/CONJ-28

      It seems that we're receiving a byte array instead of string though we're not using a secured connexion to the database.

      Attachments

        1. classcast_java_exception.txt
          12 kB
          Julien Stegle
        2. classcast_procedure.txt
          2 kB
          Julien Stegle

        Activity

          People

            diego dupin Diego Dupin
            Stegle Julien Stegle
            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.