HHH-18332 Fix DB2 support for procedure output ref_cursors parameters

This commit is contained in:
Marco Belladelli 2024-07-03 12:05:11 +02:00
parent 4c64ddc153
commit f292908b67
2 changed files with 46 additions and 0 deletions

View File

@ -777,11 +777,24 @@ public class DB2LegacyDialect extends Dialect {
return "nullif(" + literal + "," + literal + ')';
}
@Override
public Boolean supportsRefCursors() {
// DB2 supports the binding with Types.REF_CURSOR but doesn't support statement.getObject(position, ResultSet.class)
return false;
}
@Override
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
statement.registerOutParameter( col++, Types.REF_CURSOR );
return col;
}
@Override
public int registerResultSetOutParameter(CallableStatement statement, String name) throws SQLException {
statement.registerOutParameter( name, Types.REF_CURSOR );
return 1;
}
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
boolean isResultSet = ps.execute();
@ -793,6 +806,16 @@ public class DB2LegacyDialect extends Dialect {
return ps.getResultSet();
}
@Override
public ResultSet getResultSet(CallableStatement statement, int position) throws SQLException {
return (ResultSet) statement.getObject( position );
}
@Override
public ResultSet getResultSet(CallableStatement statement, String name) throws SQLException {
return (ResultSet) statement.getObject( name );
}
@Override
public boolean supportsCommentOn() {
return true;

View File

@ -851,11 +851,24 @@ public class DB2Dialect extends Dialect {
return "nullif(" + literal + "," + literal + ')';
}
@Override
public Boolean supportsRefCursors() {
// DB2 supports the binding with Types.REF_CURSOR but doesn't support statement.getObject(position, ResultSet.class)
return false;
}
@Override
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
statement.registerOutParameter( col++, Types.REF_CURSOR );
return col;
}
@Override
public int registerResultSetOutParameter(CallableStatement statement, String name) throws SQLException {
statement.registerOutParameter( name, Types.REF_CURSOR );
return 1;
}
@Override
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
boolean isResultSet = ps.execute();
@ -867,6 +880,16 @@ public class DB2Dialect extends Dialect {
return ps.getResultSet();
}
@Override
public ResultSet getResultSet(CallableStatement statement, int position) throws SQLException {
return (ResultSet) statement.getObject( position );
}
@Override
public ResultSet getResultSet(CallableStatement statement, String name) throws SQLException {
return (ResultSet) statement.getObject( name );
}
@Override
public boolean supportsCommentOn() {
return true;