Re: Strange error using postgres 8.2 + JDBC 8.2 driver - Mailing list pgsql-jdbc

From Csaba Nagy
Subject Re: Strange error using postgres 8.2 + JDBC 8.2 driver
Date
Msg-id 1169054662.22307.305.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: Strange error using postgres 8.2 + JDBC 8.2 driver  (Csaba Nagy <nagy@ecircle-ag.com>)
List pgsql-jdbc
On Wed, 2007-01-17 at 18:13, Csaba Nagy wrote:
> > This will actually happen in 8.1 servers if you are running the latest
> > releases.  Previously, inserting something like "a\0b" would silently
> > truncate at the null byte, but now it's an error.  So, check your data for
> > \0.

OK, I was able to reproduce it using:

Connection connection = getConnection();
Statement statement = connection.createStatement();
statement.execute("create table test_null_in_string (data text)");
PreparedStatement prepStatement =
  connection.prepareStatement("insert into test_null_in_string values
(?)");
String test = new String(new byte[] {1, 2, 3, 0, 1, 2, 3}, "US-ASCII");
prepStatement.setString(1, test);
// will throw exception
prepStatement.executeUpdate();


So it is easily possible... now I have to check how it happens in our
system, but I'm afraid I won't like the implications :-/

Cheers,
Csaba.



pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Strange error using postgres 8.2 + JDBC 8.2 driver
Next
From: "Guillaume Smet"
Date:
Subject: Memory leaks using refcursors