Skip to content

Commit

Permalink
Fix prepared statement setNull() #1365 (#1371)
Browse files Browse the repository at this point in the history
* Fix prepared statement setNull() #1365

* Fix missing comment (to restart the build process)
  • Loading branch information
speckyspooky authored Jul 15, 2023
1 parent 132b8b8 commit 1cc5c32
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,20 @@ public void setNull(int parameterId) throws OdaException {
try {
java.sql.ParameterMetaData pm = this.preStat.getParameterMetaData();
if (pm == null) {
this.preStat.setNull(parameterId, java.sql.Types.OTHER);
try {
this.preStat.setNull(parameterId, java.sql.Types.OTHER);
} catch (SQLException e) {
// fallback, set the null value with SQL default null type
this.preStat.setNull(parameterId, java.sql.Types.NULL);
}
addLog("setNull", parameterId, "null");
} else {
this.preStat.setNull(parameterId, pm.getParameterType(parameterId));
try {
this.preStat.setNull(parameterId, pm.getParameterType(parameterId));
} catch (SQLException e) {
// fallback, set the null value with SQL default null type
this.preStat.setNull(parameterId, java.sql.Types.NULL);
}
}
} catch (SQLException e) {
throw new JDBCException(ResourceConstants.PREPARESTATEMENT_CANNOT_SET_NULL_VALUE, e);
Expand Down Expand Up @@ -887,7 +897,7 @@ private void addLog(String methodName, Exception e) {
/**
* This API is meant to execute the update/DML sql query.
*
* @return
* @return Return the execution status
* @throws OdaException
*/
public int executeUpdate() throws OdaException {
Expand Down

0 comments on commit 1cc5c32

Please sign in to comment.