[CONJ-385] Calling stored procedure 'call RenewGet(?)' for SELECT result returns no data. Created: 2016-11-04  Updated: 2016-11-06  Resolved: 2016-11-06

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.5.4
Fix Version/s: 1.5.5

Type: Bug Priority: Major
Reporter: Seonmi Anderson Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

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 }

}



 Comments   
Comment by Diego Dupin [ 2016-11-06 ]

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

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

Generated at Thu Feb 08 03:15:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.