Re: I do not understand the exception

Lists: pgsql-jdbc
From: Jaap Bril <Jaap(dot)Bril(at)inter(dot)nl(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: I do not understand the exception
Date: 2004-08-24 10:02:31
Message-ID: 200408241202.31945.Jaap.Bril@inter.nl.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

I dont get the error here,

the exception is
SQLEXCEPTION:Storing thumbnail failed:
java.sql.SQLException: ERROR: Bad int8 external representation
"\377\330\377\340\ [.........]

The offending code is:
private void storeThumbnail(ConnectionPool connectionPool, byte[] tn) {
String thumbnail_insert = "INSERT INTO thumbnails VALUES (?)";
try {
dbConn = connectionPool.getConnection();
dbConn.setAutoCommit(false);
PreparedStatement ps = dbConn.prepareStatement(thumbnail_insert);
ps.setBytes(1, tn);
ps.executeUpdate();
ps.close();
}
catch (SQLException e){
System.out.println("SQLEX:Storing thumbnail failed: " + e );
}
}

tn is a
ByteArrayOutputStream().toByteArray() filled with a
JPEGCodec.createJPEGEncoder()

The table thumbnails has a bytea and a serial;

What can be wrong??

TIA
Jaap


From: Kris Jurka <books(at)ejurka(dot)com>
To: Jaap Bril <Jaap(dot)Bril(at)inter(dot)nl(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: I do not understand the exception
Date: 2004-08-24 15:07:02
Message-ID: Pine.BSO.4.56.0408241005450.2585@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tue, 24 Aug 2004, Jaap Bril wrote:

> the exception is
> SQLEXCEPTION:Storing thumbnail failed:
> java.sql.SQLException: ERROR: Bad int8 external representation
> "\377\330\377\340\ [.........]
>
> String thumbnail_insert = "INSERT INTO thumbnails VALUES (?)";

You are trying to put the byte array into your serial column. You need to
explicitly name the column you want in your insert statement.

Kris Jurka