From: Bruce Momjian Date: Wed, 16 May 2001 17:22:25 +0000 (+0000) Subject: This patch fixes a bug which occurs when setObject(1,obj) is called and obj X-Git-Tag: REL7_2_BETA1~1264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7934c93cbed4471e55924631fa92a83b4c32e395;p=postgresql This patch fixes a bug which occurs when setObject(1,obj) is called and obj is of type Object, and is null Dave Cramer --- diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java index 70a0b91dbd..84efeb09a0 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java @@ -455,6 +455,10 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException { + if (x == null){ + setNull(parameterIndex,Types.OTHER); + return; + } switch (targetSqlType) { case Types.TINYINT: @@ -506,6 +510,10 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setObject(int parameterIndex, Object x) throws SQLException { + if (x == null){ + setNull(parameterIndex,Types.OTHER); + return; + } if (x instanceof String) setString(parameterIndex, (String)x); else if (x instanceof BigDecimal) diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java index 5cf5152755..f204490533 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java @@ -515,6 +515,10 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException { + if (x == null){ + setNull(parameterIndex,Types.OTHER); + return; + } switch (targetSqlType) { case Types.TINYINT: @@ -566,6 +570,10 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setObject(int parameterIndex, Object x) throws SQLException { + if (x == null){ + setNull(parameterIndex,Types.OTHER); + return; + } if (x instanceof String) setString(parameterIndex, (String)x); else if (x instanceof BigDecimal)