Unix Technical Forum

Help with exception: java.lang.IllegalArgumentException: \0 not allowed

This is a discussion on Help with exception: java.lang.IllegalArgumentException: \0 not allowed within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, I was working with java.sql.PreparedStatement. I'm getting an exception "java.lang.IllegalArgumentException: \0 not allowed" while using '\0' terminated strings ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:02 PM
Venkatesh Babu
 
Posts: n/a
Default Help with exception: java.lang.IllegalArgumentException: \0 not allowed

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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 11:02 PM
Oliver Jowett
 
Posts: n/a
Default Re: Help with exception: java.lang.IllegalArgumentException:

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:04 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com