Re: Help with exception: java.lang.IllegalArgumentException:

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Venkatesh Babu <venkatbabukr(at)yahoo(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Help with exception: java.lang.IllegalArgumentException:
Date: 2005-01-31 19:34:38
Message-ID: 41FE884E.2040004@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2005-01-31 20:03:22 Re: [SPAM] - Re: [SPAM] - Re: JDBC HighLoad - Found word(s)
Previous Message Stéphane RIFF 2005-01-31 13:56:22 Re: [SPAM] - Re: [SPAM] - Re: JDBC HighLoad - Found word(s)