X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 545B5D1BAF5 for ; Wed, 23 Jun 2004 12:28:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90326-08 for ; Wed, 23 Jun 2004 15:28:30 +0000 (GMT) Received: from bonobo.illumining.com (unknown [81.187.189.76]) by svr1.postgresql.org (Postfix) with ESMTP id 1A9A9D1B289 for ; Wed, 23 Jun 2004 12:28:26 -0300 (ADT) Received: from pete ([192.168.128.102]) by bonobo.illumining.com (8.12.8/8.12.8) with SMTP id i5NFX2hY017166 for ; Wed, 23 Jun 2004 16:33:03 +0100 Message-ID: <03bc01c45936$ba49a0b0$6680a8c0@pete> From: "Pete Lewin-Harris" To: Subject: Blob getBinaryStream issue. Date: Wed, 23 Jun 2004 16:28:05 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/154 X-Sequence-Number: 10356 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