Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 43892 invoked from network); 15 Mar 2011 23:25:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Mar 2011 23:25:51 -0000 Received: (qmail 21468 invoked by uid 500); 15 Mar 2011 23:25:51 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 21432 invoked by uid 500); 15 Mar 2011 23:25:51 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 21425 invoked by uid 99); 15 Mar 2011 23:25:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2011 23:25:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Mar 2011 23:25:50 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id BF8CD3AB39A for ; Tue, 15 Mar 2011 23:25:29 +0000 (UTC) Date: Tue, 15 Mar 2011 23:25:29 +0000 (UTC) From: "Unai Vivi (JIRA)" To: derby-dev@db.apache.org Message-ID: <586662927.5436.1300231529781.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <259304388.11173.1299171097097.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Commented: (DERBY-5090) Retrieving BLOB fields sometimes fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5090?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13007274#comment-13007274 ] Unai Vivi commented on DERBY-5090: ---------------------------------- Oops, how stupid of me to miss that note in the ResultSet's javadoc... I'm glad I put the newcomer "disclaimer" :) Anyways, it's good that this helped to point out that there's this difference between embedded and client drivers, where the former gives a null string message while the latter very helpfully says that the stream is closed. The second inconsistency you found is interesting too, where if the Blob is bigger than a page only the client driver throws the object-closed exception while the embedded driver doesn't. > Retrieving BLOB fields sometimes fails > -------------------------------------- > > Key: DERBY-5090 > URL: https://issues.apache.org/jira/browse/DERBY-5090 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.7.1.1 > Environment: JDBC derby embedded driver > Reporter: Unai Vivi > Labels: BLOB, Ordering, exception, null, order, read > Attachments: Derby5090.java, Derby5090_2.java > > > This is my first issue report, so please be understanding if I'm posting the wrong thing, in the wrong place or in the wrong way. I just want to help. :) > While iterating through a ResultSet, when accessing a BLOB field to read its contents via an InputStream, I noticed that: > - if the current ResultSet's has been "warmed up" by retrieving another column first, everything it's fine; > - if, on the other hand, you first-thing access the BLOB (and read other columns later), then upon reading the first byte out the InputStream bound to the BLOB field (ResultSet.getBinaryStream("col_name")) an IOException is thrown (and IOException's getMessage() method returns null). > Following is an example, taken from a real application. The two code segments only differ in the fact that a SMALLINT & VARCHAR read is done before/after the BLOB read. > --Working snippet-- > [...] > icRelPath[i] = "imm" + File.separator + "ic" + "_" + rs.getShort("setIcone") + "_" + i + "." + rs.getString("estensione"); > AutoCloseInputStream acis = new AutoCloseInputStream(rs.getBinaryStream("ic" + i)); > if (rs.wasNull()) > icRelPath[i] = null; > else > { > //icRelPath[i] = "imm" + File.separator + "ic" + "_" + rs.getShort("setIcone") + "_" + i + "." + rs.getString("estensione"); > BufferedInputStream bis = new BufferedInputStream(acis); > int b = bis.read();//READS FINE > [...] > --Broken snippet-- > [...] > //icRelPath[i] = "imm" + File.separator + "ic" + "_" + rs.getShort("setIcone") + "_" + i + "." + rs.getString("estensione"); > AutoCloseInputStream acis = new AutoCloseInputStream(rs.getBinaryStream("ic" + i)); > if (rs.wasNull()) > icRelPath[i] = null; > else > { > icRelPath[i] = "imm" + File.separator + "ic" + "_" + rs.getShort("setIcone") + "_" + i + "." + rs.getString("estensione"); > BufferedInputStream bis = new BufferedInputStream(acis); > int b = bis.read();//THROWS IOException WITH A null ERROR MESSAGE STRING > [...] -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira