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

Calling stored procedure 'call RenewGet(?)' for SELECT result returns no data.

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.5.4
    • 1.5.5
    • Other
    • None
    • AWS Aurora MySQL 5.6
      Java 1.8
      spring jdbc 4.2.5

    Description

      I am trying to upgrade maraidb-java-client from 1.4.6 to 1.5.4 to support cluster endpoint but I am not able to upgrade it because calling 'execute(SqlParameterSource)' method in SimpleJdbcCall won't return result as like 1.4.6 does.

      Here is sample client code that trying to retrieve data from MySSQL stored procedure;
      public List<Renew> findById(Integer id) {
      SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate)
      .withProcedureName("RenewGet")
      .withoutProcedureColumnMetaDataAccess()
      .declareParameters(
      new SqlParameter("idIn", Types.INTEGER))
      .returningResultSet("items", new RenewMapper());

      SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("id", id);

      Map<String, Object> out = null;
      try

      { out = jdbcCall.execute(sqlParameterSource); }

      finally {}

      return (List<Renew>) out.get("items");
      }

      It expects output return 'items' that containing result but failed to return data. It is because getUpdateCount() in MariaDBStatement class returns 0 instead of -1 in 1.5.4, so JdbcTemplate won't put the result into output (returnedResult).

      version 1.5.4;
      public int getUpdateCount() throws SQLException {
      if (executionResult == null)

      { return -1; /* Result comes from SELECT , or there are no more results */ }
      if (executionResult.isSingleExecutionResult()) { return (int) ((SingleExecutionResult) executionResult).getAffectedRows(); } else { return ((MultiExecutionResult) executionResult).getFirstAffectedRows(); }
      }

      version 1.4.6
      public int getUpdateCount() throws SQLException {
      if (executionResult == null || executionResult.getResult() != null) { return -1; /* Result comes from SELECT , or there are no more results */ }

      if (executionResult instanceof SingleExecutionResult)

      { // same as above }

      }

      Attachments

        Activity

          diego dupin Diego Dupin added a comment -

          confirmed : getUpdateCount() for callableStatement return 0 instead of -1 when returning resultset.

          fixed with commit : https://github.com/MariaDB/mariadb-connector-j/commit/6190081f0106466da40d8181adf6e45f576884c3

          diego dupin Diego Dupin added a comment - confirmed : getUpdateCount() for callableStatement return 0 instead of -1 when returning resultset. fixed with commit : https://github.com/MariaDB/mariadb-connector-j/commit/6190081f0106466da40d8181adf6e45f576884c3

          People

            diego dupin Diego Dupin
            seanderson Seonmi Anderson
            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.