]> granicus.if.org Git - postgresql/commitdiff
This patch fixes a bug which occurs when setObject(1,obj) is called and obj
authorBruce Momjian <bruce@momjian.us>
Wed, 16 May 2001 17:22:25 +0000 (17:22 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 16 May 2001 17:22:25 +0000 (17:22 +0000)
is of type Object, and is null

Dave Cramer

src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java
src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java

index 70a0b91dbd5d4d4769b0b00462fc842d136586f9..84efeb09a06e0dd1c153e2d651a904e6b2cb3b51 100644 (file)
@@ -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)
index 5cf515275529a19d8cf7e053ec09d66352f1e628..f204490533cc240e3fddc3fb86631a2d73b97adb 100644 (file)
@@ -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)