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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
|
|