Got two patches that were found by folks on the Castor list, that we'd like to
authorBruce Momjian
Mon, 11 Jun 2001 22:12:00 +0000 (22:12 +0000)
committerBruce Momjian
Mon, 11 Jun 2001 22:12:00 +0000 (22:12 +0000)
submit.  These were done for the jdbc2 driver.  The first one is for support
of the Types.BIT in the PreparedStatement class.  The following lines need to be
inserted in the switch statment, at around line 530:

(Prepared statment, line 554, before the default: switch
case Types.BIT:
     if (x instanceof Boolean) {
          set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
     } else {
          throw new PSQLException("postgresql.prep.type");
     }
     break;

The second one is dealing with blobs,

inserted in PreparedStatemant.java (After previous patch line, 558):
         case Types.BINARY:
         case Types.VARBINARY:
                              setObject(parameterIndex,x);
                              break;
and in ResultSet.java (Around line 857):
        case Types.BINARY:
        case Types.VARBINARY:
                        return getBytes(columnIndex);

Ned Wolpert 

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

index 84efeb09a06e0dd1c153e2d651a904e6b2cb3b51..e4c50f13af9164bf9e7839accd351b36d53c270d 100644 (file)
@@ -489,6 +489,17 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
            case Types.TIMESTAMP:
                setTimestamp(parameterIndex, (Timestamp)x);
                break;
+           case Types.BIT:
+               if (x instanceof Boolean) {
+                   set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
+               } else {
+                   throw new PSQLException("postgresql.prep.type");
+               }
+               break;
+           case Types.BINARY:
+           case Types.VARBINARY:
+               setObject(parameterIndex,x);
+               break;
            case Types.OTHER:
                setString(parameterIndex, ((PGobject)x).getValue());
                break;
index 98af07b0b63bd001e0e1c3f5fd5ddd0d8ca007eb..bfbded0f01c99c82bcda1af500d163f6006e93b1 100644 (file)
@@ -806,6 +806,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
    return getTime(columnIndex);
       case Types.TIMESTAMP:
    return getTimestamp(columnIndex);
+      case Types.BINARY:
+      case Types.VARBINARY:
+   return getBytes(columnIndex);   
       default:
    return connection.getObject(field.getTypeName(), getString(columnIndex));
       }
index f204490533cc240e3fddc3fb86631a2d73b97adb..af73fee3626d0cd7dcc91538a04950fe1b2217de 100644 (file)
@@ -549,6 +549,17 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
            case Types.TIMESTAMP:
                setTimestamp(parameterIndex, (Timestamp)x);
                break;
+           case Types.BIT:
+               if (x instanceof Boolean) {
+                   set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
+               } else {
+                   throw new PSQLException("postgresql.prep.type");
+               }
+               break;
+           case Types.BINARY:
+           case Types.VARBINARY:
+               setObject(parameterIndex,x);
+               break;
            case Types.OTHER:
                setString(parameterIndex, ((PGobject)x).getValue());
                break;
index 81605deec8eeaa384ee4e4b1e69b1d62a59a7372..5bf11e3c3eba94dedcd97f1c127a2d3adf7dabce 100644 (file)
@@ -855,6 +855,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
    return getTime(columnIndex);
       case Types.TIMESTAMP:
    return getTimestamp(columnIndex);
+      case Types.BINARY:
+      case Types.VARBINARY:
+   return getBytes(columnIndex);   
       default:
    return connection.getObject(field.getTypeName(), getString(columnIndex));
       }