Bug with blobs?

From: Rob Kirkbride <rob(at)rkcomputing(dot)co(dot)uk>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Bug with blobs?
Date: 2005-08-11 18:09:48
Message-ID: 42FB946C.2090603@rkcomputing.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I was getting an exception thrown when using Hibernate to read blobs but
I've pared it down to something very simple - hopefully it's just
something silly.
Here's the snippet of code :-

String query = "select imageblob from tempimages where id=1";

Connection con;
PreparedStatement s;
ResultSet rs;

try {
Class.forName(driver);
con = DriverManager.getConnection(url, username,
password);
s = con.prepareStatement(query);
rs = s.executeQuery();
rs.next();
java.sql.Blob blob = rs.getBlob("imageblob");

It throws a
org.postgresql.util.PSQLException: Bad value for type int :
\377\330\377\340\000 .... <blob data removed>
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2528)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:2003)
at org.postgresql.jdbc3.Jdbc3ResultSet.getBlob(Jdbc3ResultSet.java:55)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBlob(AbstractJdbc2ResultSet.java:323)
at PgTest.run(PgTest.java:46)
at PgTest.main(PgTest.java:63)

This is with postgresql 8.0.3 and version 312 of the driver (on Linux)

Help, help! - What am I doing wrong!?

Thanks for any help,

Rob

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2005-08-11 18:36:14 Re: Bug with blobs?
Previous Message Mark Lewis 2005-08-11 17:55:04 Re: Memory leak in 8.0 JDBC driver?