Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 38E6614EC67B for ; Mon, 14 Nov 2011 12:31:04 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 34664-04 for ; Mon, 14 Nov 2011 16:31:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id ECE6F14EC67A for ; Mon, 14 Nov 2011 12:31:02 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id pAEGV208071874 for ; Mon, 14 Nov 2011 16:31:02 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id pAEGV2pt071873; Mon, 14 Nov 2011 16:31:02 GMT (envelope-from www) Date: Mon, 14 Nov 2011 16:31:02 GMT Message-Id: <201111141631.pAEGV2pt071873@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6292: java.sql.PreparedStatement.setNull() throws PSQLException From: "David Pinheiro" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201111/104 X-Sequence-Number: 31699 The following bug has been logged online: Bug reference: 6292 Logged by: David Pinheiro Email address: davidsantospinheiro@gmail.com PostgreSQL version: 8.4 Operating system: Linux Description: java.sql.PreparedStatement.setNull() throws PSQLException Details: I'm trying to make: java.sql.PreparedStatement.setNull(1,java.sql.Types.NULL); But i get: org.postgresql.util.PSQLException: ERROR: column "number_column" is of type integer but expression is of type character varying Hint: You will need to rewrite or cast the expression. My code is something like: if (String.valueOf(input_field) == "null"){ statement.setNull(1, java.sql.Types.NULL); } else { statement.setObject(1, valor); } statement.executeUpdate(); Java says: org.postgresql.util.PSQLException: ERROR: column "number_column" is of type integer but expression is of type character varying Hint: You will need to rewrite or cast the expression. Position: 159 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI mpl.java:2096) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.ja va:1829) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.j ava:510) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2St atement.java:386) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2State ment.java:332) at pt.cm_olhao.tecidoempresarial.database.estabelecimentos.EstabelecimentosFree formStatementDelegate.storeRow(EstabelecimentosFreeformStatementDelegate.jav a:160) I have Postgresql 8.4 and postgresql-jdbc-8.4-703. Thanks a lot! David Pinheiro