Re: Bug: Cannot pass null in Parameter in Query for ISNULL

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: bht(at)actrix(dot)gen(dot)nz
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bug: Cannot pass null in Parameter in Query for ISNULL
Date: 2011-11-30 07:04:43
Message-ID: CA+0W9LM4xcS0r=X_TwUA4kJKpat+1WitY01eB8WD6Rgzj=i0mg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 30 November 2011 20:01, Oliver Jowett <oliver(at)opencloud(dot)com> wrote:

> This is specific to calling PreparedStatement.setObject(index, null).

> To avoid this, use one of these instead:
>
>  * PreparedStatement.setObject(index, null, type)
>  * PreparedStatement.set<type>(index, null)
>  * PreparedStatement.setNull(index, type)
>
> all of which provide type information that the driver needs.

I'd also refer you to the JDBC javadoc for setObject(int,Object) which says:

==
Note: Not all databases allow for a non-typed Null to be sent to the
backend. For maximum portability, the setNull or the setObject(int
parameterIndex, Object x, int sqlType) method should be used instead
of setObject(int parameterIndex, Object x).
==

Oliver

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message bht 2011-11-30 07:36:02 Re: Bug: Cannot pass null in Parameter in Query for ISNULL
Previous Message Oliver Jowett 2011-11-30 07:01:52 Re: Bug: Cannot pass null in Parameter in Query for ISNULL