pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Venkatesh Babu <venkatbabukr@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Help with exception: java.lang.IllegalArgumentException:
Date: Tue, 01 Feb 2005 08:34:38 +1300
Message-ID: <41FE884E.2040004@opencloud.com> (raw)
In-Reply-To: <20050131072145.83421.qmail@web50402.mail.yahoo.com>
References: <20050131072145.83421.qmail@web50402.mail.yahoo.com>

Venkatesh Babu wrote:

> I'm getting an exception
> "java.lang.IllegalArgumentException: \0 not allowed"
> while using '\0' terminated strings as parameters for
> the PreparedStatement. May I know whether usage of
> such strings is not permitted? I'm using the
> PreparedStatement.setString(int parameterIndex, String
> x) function to set the parameters and I get the
> exception here.

You can't use \0 in text types (text, varchar, char, etc); this is a 
limitation of the server and the server/client protocol. The driver is 
just catching it early so you don't see strange behaviour later.

In general, you don't need to terminate Java strings with \0 at all. If 
you really do need to store a literal NUL, consider using a bytea column 
and PreparedStatement.setBytes() instead.

-O



view thread (2+ messages)

Message-ID: <41FE884E.2040004@opencloud.com>
Permalink:  ../41FE884E.2040004@opencloud.com/
Also on:    postgresql.org/message-id/41FE884E.2040004@opencloud.com

 · 

reply

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, venkatbabukr@yahoo.com
  Subject: Re: Help with exception: java.lang.IllegalArgumentException:
  In-Reply-To: <41FE884E.2040004@opencloud.com>
  References: <20050131072145.83421.qmail@web50402.mail.yahoo.com> <41FE884E.2040004@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