From: Oliver Jowett <oliver@opencloud.com>
To: Tim Penhey <tim@penhey.net>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: PreparedStatement.setString with null
Date: Thu, 30 Sep 2004 22:34:25 +1200
Message-ID: <415BE131.8080203@opencloud.com> (raw)
In-Reply-To: <415BD807.6040103@penhey.net>
References: <415BD807.6040103@penhey.net>
Tim Penhey wrote:
> What is this supposed to do?
>
> PreparedStatement stat = connection.prepareStatement("update table1
> set col1 = ?");
> stat.setString(1, null);
>
> Will this make a null value in the database or an empty string? Do we
> have to use the setNull(1, Types.VARCHAR) in order to get a null value
> entered?
The postgresql JDBC driver treats setString(x, null) identically to
setNull(x, Types.VARCHAR). I don't know how portable this behaviour is;
the javadoc is silent on how this case should be handled. You're
probably better off using setNull() explicitly.
-O
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: oliver@opencloud.com, tim@penhey.net
Subject: Re: PreparedStatement.setString with null
In-Reply-To: <415BE131.8080203@opencloud.com>
References: <415BD807.6040103@penhey.net> <415BE131.8080203@opencloud.com>
* 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