]> granicus.if.org Git - postgresql/commitdiff
Applied patch from Kim Ho at redhat to improve boolean and bit handling
authorBarry Lind <barry@xythos.com>
Wed, 17 Sep 2003 05:07:38 +0000 (05:07 +0000)
committerBarry Lind <barry@xythos.com>
Wed, 17 Sep 2003 05:07:38 +0000 (05:07 +0000)
in the jdbc driver

 Modified Files:
  jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
  jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java

index 979ae4d1ec9229f648d8695521457107e1691bc2..93133c51d6f1b6c58e0367a9ac058e9b4b7ce6bc 100644 (file)
@@ -26,7 +26,7 @@ import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.Vector;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.36 2003/09/13 04:02:15 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.37 2003/09/17 05:07:37 barry Exp $
  * This class defines methods of the jdbc1 specification.  This class is
  * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
  * methods.  The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -917,7 +917,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
         */
        public void setBoolean(int parameterIndex, boolean x) throws SQLException
        {
-               bind(parameterIndex, x ? "'t'" : "'f'", PG_BOOLEAN);
+               bind(parameterIndex, x ? "'1'" : "'0'", PG_BOOLEAN);
        }
 
        /*
@@ -1551,11 +1551,15 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
                        case Types.BIT:
                                if (x instanceof Boolean)
                                {
-                                       bind(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE", PG_TEXT);
+                                       bind(parameterIndex, ((Boolean)x).booleanValue() ? "'1'" : "'0'", PG_BOOLEAN);
+                               }
+                               else if (x instanceof String)
+                               {
+                                       bind(parameterIndex, Boolean.valueOf(x.toString()).booleanValue() ? "'1'" : "'0'", PG_BOOLEAN);
                                }
                                else if (x instanceof Number)
                                {
-                                       bind(parameterIndex, ((Number)x).intValue()==1 ? "TRUE" : "FALSE", PG_TEXT);
+                                       bind(parameterIndex, ((Number)x).intValue()==1 ? "'1'" : "'0'", PG_BOOLEAN);
                                }
                                else
                                {
index 9db54ae215170880a6a98d7021850bcc13487e7b..25a6a003c6391569e3f4c1796d0d68a2ecef386d 100644 (file)
@@ -5,7 +5,7 @@ import java.math.BigDecimal;
 import java.sql.*;
 import java.util.Calendar;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.3 2003/09/17 05:07:38 barry Exp $
  * This class defines methods of the jdbc3 specification.  This class extends
  * org.postgresql.jdbc2.AbstractJdbc2Statement which provides the jdbc2
  * methods.  The real Statement class (for jdbc2) is org.postgresql.jdbc3.Jdbc3Statement
@@ -1359,5 +1359,16 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
        {
                throw org.postgresql.Driver.notImplemented();
        }
+       
+       public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
+       {
+               switch (targetSqlType)
+               {
+                       case Types.BOOLEAN:
+                               super.setObject(parameterIndex, x, Types.BIT, scale);
+                       default:
+                               super.setObject(parameterIndex, x, targetSqlType, scale);
+               }
+       }
 
 }