pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Help with exception: java.lang.IllegalArgumentException: \0 not allowed
2+ messages / 2 participants
[nested] [flat]

* Help with exception: java.lang.IllegalArgumentException: \0 not allowed
@ 2005-01-31 07:21 Venkatesh Babu <venkatbabukr@yahoo.com>
  2005-01-31 19:34 ` Re: Help with exception: java.lang.IllegalArgumentException: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Venkatesh Babu @ 2005-01-31 07:21 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,

I was working with java.sql.PreparedStatement. 

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.

FYI, I'm using the JDBC driver pg74.213.jdbc2.jar, for
Postgres 7.4.

Thanks,
Venkatesh


		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Help with exception: java.lang.IllegalArgumentException:
  2005-01-31 07:21 Help with exception: java.lang.IllegalArgumentException: \0 not allowed Venkatesh Babu <venkatbabukr@yahoo.com>
@ 2005-01-31 19:34 ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2005-01-31 19:34 UTC (permalink / raw)
  To: Venkatesh Babu <venkatbabukr@yahoo.com>; +Cc: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-01-31 19:34 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-31 07:21 Help with exception: java.lang.IllegalArgumentException: \0 not allowed Venkatesh Babu <venkatbabukr@yahoo.com>
2005-01-31 19:34 ` Re: Help with exception: java.lang.IllegalArgumentException: Oliver Jowett <oliver@opencloud.com>

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