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 1FFB052951 for ; Mon, 20 Jun 2005 07:05:36 -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 97896-09 for ; Mon, 20 Jun 2005 10:05:34 +0000 (GMT) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.207]) by svr1.postgresql.org (Postfix) with ESMTP id 23CDC52908 for ; Mon, 20 Jun 2005 07:05:33 -0300 (ADT) Received: by nproxy.gmail.com with SMTP id g2so27964nfe for ; Mon, 20 Jun 2005 03:05:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=UDv52MfaRcnkF9p+oeQo7xCuabaxV2iyLbNI1j3pLk56aKauq2E40G0p8nZXl4qwuYSQF7ygc6VbxfXD5rd8To2z8kBMr/qZdqLsi3M+xnHnp2ZdpR/tZIuYp8WRei6hbcb9vrfHYOzFbKa82IXq06PMp036jyfZUhn1TYMSOFM= Received: by 10.48.249.6 with SMTP id w6mr77996nfh; Mon, 20 Jun 2005 03:05:35 -0700 (PDT) Received: by 10.48.249.2 with HTTP; Mon, 20 Jun 2005 03:05:35 -0700 (PDT) Message-ID: <224f3234050620030565ffa711@mail.gmail.com> Date: Mon, 20 Jun 2005 12:05:35 +0200 From: Thomas Dudziak Reply-To: Thomas Dudziak To: pgsql-jdbc@postgresql.org Subject: Exception when inserting boolean values into BIT columns Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/101 X-Sequence-Number: 13063 I have a problem with BIT datatypes accessed via JDBC. When I try to insert a Boolean value via a PreparedStatement, I get the following exception (using the newest JDBC driver, postgresql-8.0-311.jdbc3.jar, against a 8.0.1 database on Windows, Java is 1.5.0_1): Exception in thread "main" java.sql.SQLException: ERROR: column "isok" is of type bit but expression is of type boolean =09at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryEx= ecutorImpl.java:1471) =09at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutor= Impl.java:1256) =09at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.ja= va:175) =09at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat= ement.java:389) =09at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(Abstract= Jdbc2Statement.java:330) =09at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat= ement.java:321) =09at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(Delegatin= gPreparedStatement.java:168) =09at Main.main(Main.java:27) This is the corresponding test code: import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.Statement; import java.sql.Types; import org.apache.commons.dbcp.BasicDataSource; public class Main { public static void main(String[] args) throws Exception { BasicDataSource dataSource =3D new BasicDataSource(); dataSource.setDriverClassName("org.postgresql.Driver"); dataSource.setUrl("jdbc:postgresql://localhost/test"); dataSource.setUsername("postgres"); dataSource.setPassword("root123"); Connection connection =3D dataSource.getConnection(); Statement statement =3D connection.createStatement(); statement.execute("CREATE TABLE Test(id SERIAL, isOk BIT);"); statement.close(); PreparedStatement prepStatement =3D connection.prepareStatement("INSERT INTO Test (isOk) VALUES (?);"); prepStatement.setObject(1, Boolean.TRUE, Types.BIT); prepStatement.execute(); prepStatement.close(); connection.close(); } } (btw, the same exception is generated when using setBoolean instead of setObject.) Any ideas ? regards, Tom