Skip site navigation (1) Skip section navigation (2)

Blob getBinaryStream issue.

From: "Pete Lewin-Harris" <pete(at)illumining(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Blob getBinaryStream issue.
Date: 2004-06-23 15:28:05
Message-ID: 03bc01c45936$ba49a0b0$6680a8c0@pete (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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 =

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

    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


pgsql-jdbc by date

Next:From: Oliver JowettDate: 2004-06-24 02:38:48
Subject: Re: PoolingDataSource executeUpdate
Previous:From: Dave CramerDate: 2004-06-23 14:39:13
Subject: Re: ConnectionPooling executeUpdate

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group