X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 228F853B40 for ; Thu, 14 Apr 2005 12:46:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18119-02 for ; Thu, 14 Apr 2005 15:45:28 +0000 (GMT) Received: from web50407.mail.yahoo.com (web50407.mail.yahoo.com [206.190.38.72]) by svr1.postgresql.org (Postfix) with SMTP id D545953BEF for ; Thu, 14 Apr 2005 12:45:15 -0300 (ADT) Received: (qmail 66804 invoked by uid 60001); 14 Apr 2005 15:45:08 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=m+OkIbcHO8RZmb3K66cTglmxF4NPu27z0djLpYsQ0UfLjd7PgkCf7mhdwGWiFPGgDSrB9gkl4/7e4IP1XzgobOpCJRix+HtL8t8/B4O6S85yNN+WvNElB5Bw304zo/jXS65ehVT5uq2PgQLXRO7BleIIx/CVXBpG0m816f1UZ7c= ; Message-ID: <20050414154508.66799.qmail@web50407.mail.yahoo.com> Received: from [69.17.136.24] by web50407.mail.yahoo.com via HTTP; Thu, 14 Apr 2005 08:45:07 PDT Date: Thu, 14 Apr 2005 08:45:07 -0700 (PDT) From: bst Subject: Bit string type in PreparedStatement To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200504/84 X-Sequence-Number: 12691 I have a table with a bit string field CREATE TABLE test (a BIT(8)); When I get the type of this filed from Java Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery("SELECT a FROM test"); ResultSetMetaData rsmd = rs.getMetaData(); int type = rsmd.getColumnType(1); String name = rsmd.getColumnTypeName(1); I get type=-7 that is equal to java.sql.Types.BIT name=bit Now I'd like to set the field in a PreparedStatement PreparedStatement update = connection.prepareStatement("UPDATE test SET a=?"); update.setObject(1, "B10101010", java.sql.Types.BIT); update.executeUpdate(); and I get org.postgresql.util.PSQLException: ERROR: column "a" is of type bit but expression is of type boolean How can I set bit string field in PreparedStatement? Thanks. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com