Voici le code que j'utilise pour un appel à une fonction :
RowMapper<String> rm = new ParameterizedRowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
};
myStoredProcedure = new SimpleJdbcCall(DataSourceConnection.getDataSource())
.withCatalogName("PACKAGE")
.withFunctionName("GET_ALIAS")
.returningResultSet("return", rm);
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("P_ID",userStr);
params.addValue("P_DOMAIN_ALIAS", domain[0]);
List<String> list = myStoredProcedure.executeFunction(List.class,params);
et si vous n'êtes pas en mesure d'utiliser les métadonnées, voici le code :
RowMapper<String> rm = new ParameterizedRowMapper<String>() {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}
};
SqlParameter emailParam = new SqlParameter("P_ID", OracleTypes.VARCHAR);
SqlParameter domainParam = new SqlParameter("P_DOMAIN_ALIAS", OracleTypes.VARCHAR);
SqlOutParameter resultParam = new SqlOutParameter("return", OracleTypes.CURSOR);
myStoredProcedure = new SimpleJdbcCall(DataSourceConnection.getDataSource())
.withCatalogName("PACKAGE")
.withFunctionName("GET_ALIAS")
.withoutProcedureColumnMetaDataAccess()
.returningResultSet("return", rm)
.declareParameters(resultParam, emailParam, domainParam);
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("P_ID",userStr);
params.addValue("P_DOMAIN_ALIAS", domain[0]);
List<String> list = myStoredProcedure.executeFunction(List.class,params);