pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Kirkbride <rob@rkcomputing.co.uk>
To: pgsql-jdbc@postgresql.org
Subject: Bug with blobs?
Date: Thu, 11 Aug 2005 19:09:48 +0100
Message-ID: <42FB946C.2090603@rkcomputing.co.uk> (raw)

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







view thread (3+ messages)  latest in thread

Message-ID: <42FB946C.2090603@rkcomputing.co.uk>
Permalink:  ../42FB946C.2090603@rkcomputing.co.uk/
Also on:    postgresql.org/message-id/42FB946C.2090603@rkcomputing.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: rob@rkcomputing.co.uk
  Subject: Re: Bug with blobs?
  In-Reply-To: <42FB946C.2090603@rkcomputing.co.uk>
  References: <42FB946C.2090603@rkcomputing.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox