Re: Strange error using postgres 8.2 + JDBC 8.2 driver

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Postgres JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Strange error using postgres 8.2 + JDBC 8.2 driver
Date: 2007-01-17 17:24:22
Message-ID: 1169054662.22307.305.camel@coppola.muc.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Guillaume Smet 2007-01-17 18:53:21 Memory leaks using refcursors
Previous Message Kris Jurka 2007-01-17 17:20:04 Re: Strange error using postgres 8.2 + JDBC 8.2 driver