pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pete Lewin-Harris <pete@illumining.com>
To: pgsql-jdbc@postgresql.org
Subject: Blob getBinaryStream issue.
Date: Wed, 23 Jun 2004 16:28:05 +0100
Message-ID: <03bc01c45936$ba49a0b0$6680a8c0@pete> (raw)

I'm getting an odd result when I try and get the length of a blob after I
have closed it's binary stream. In the snippet below, the final line throws
a PSQL Exception with the message 'FastPath call returned ERROR: invalid
large-object descriptor: 0'. If the final line is removed and
getBinaryStream called again, the second stream fails on first read with a
null pointer exception.

Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery("SELECT blobdata from mytable where id =
1");

if (rs.next())
{
    Blob blob = rs.getBlob(1);
    InputStream is = blob.getBinaryStream();
    is.close();

    long len = blob.length();
}

Two questions, really.

Firstly, is it a bug that multiple calls to getBinaryStream do not return
separate InputStream objects or is it just the way it works and I need to
re-get the blob if I want to read the stream again?

Secondly, If this is the correct behaviour the shouldn't the exceptions
thrown be slightly more friendly? Perhaps calling getBinaryStream after the
stream has been closed should return null?


cheers, Pete






view thread (2+ messages)  latest in thread

Message-ID: <03bc01c45936$ba49a0b0$6680a8c0@pete>
Permalink:  ../03bc01c45936$ba49a0b0$6680a8c0@pete/
Also on:    postgresql.org/message-id/03bc01c45936$ba49a0b0$6680a8c0@pete

 · 

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: pete@illumining.com
  Subject: Re: Blob getBinaryStream issue.
  In-Reply-To: <03bc01c45936$ba49a0b0$6680a8c0@pete>
  References: <03bc01c45936$ba49a0b0$6680a8c0@pete>

* 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