From: David Pinheiro <davidsantospinheiro@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6292: java.sql.PreparedStatement.setNull() throws PSQLException
Date: Mon, 14 Nov 2011 16:31:02 GMT
Message-ID: <201111141631.pAEGV2pt071873@wwwmaster.postgresql.org> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: davidsantospinheiro@gmail.com, pgsql-bugs@postgresql.org
Subject: Re: BUG #6292: java.sql.PreparedStatement.setNull() throws PSQLException
In-Reply-To: <201111141631.pAEGV2pt071873@wwwmaster.postgresql.org>
References: <201111141631.pAEGV2pt071873@wwwmaster.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox