Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 98452 invoked from network); 11 Apr 2011 21:17:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Apr 2011 21:17:47 -0000 Received: (qmail 62313 invoked by uid 500); 11 Apr 2011 21:17:46 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 62295 invoked by uid 500); 11 Apr 2011 21:17:46 -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 62288 invoked by uid 99); 11 Apr 2011 21:17:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2011 21:17:46 +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; Mon, 11 Apr 2011 21:17:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id BD7B99D4CA for ; Mon, 11 Apr 2011 21:17:05 +0000 (UTC) Date: Mon, 11 Apr 2011 21:17:05 +0000 (UTC) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Message-ID: <700218801.50525.1302556625772.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1085426655.43401.1302255065733.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (DERBY-5183) Cannot get BLOB value in the result set MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-5183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13018574#comment-13018574 ] Knut Anders Hatlen commented on DERBY-5183: ------------------------------------------- Which version of Derby is this? From the stack trace, it looks like you're running with 10.5 or older. A number of fixes have gone into that code since then. I'm not sure if any of them fixes the problem you're seeing, but it may be worthwhile checking if it's still a problem with a more recent version of Derby. The bug seems to be triggered by some specific values in the table. If you could provide some more details about the values in the failing row (preferably code that creates and populates a table that shows this problem) it may be easier for others to reproduce the bug and see what the problem is. > Cannot get BLOB value in the result set > --------------------------------------- > > Key: DERBY-5183 > URL: https://issues.apache.org/jira/browse/DERBY-5183 > Project: Derby > Issue Type: Bug > Components: Eclipse Plug-in > Reporter: dingyan > > There is a table include BLOB and CLOB data,column 3 is CLOB and column 4 is BLOB > when i try to get the data from this table,in some cases,SQLException is thrown :The data in this BLOB or CLOB is no longer available. The BLOB/CLOB's transaction may be committed, or its connection is closed > when i get the CLOB and BLOB data without the stream read,it is ok,my test source code as below: > import java.io.InputStream; > import java.sql.Clob; > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.ResultSetMetaData; > import java.sql.SQLException; > public class Test { > public static String driverClass = "org.apache.derby.jdbc.EmbeddedDriver"; > public static String driverURL = "jdbc:derby:d:\\BirtSample"; > public static String user = "ClassicModels"; > public static String squery = "select * from CLASSICMODELS.PRODUCTLINES,CLASSICMODELS.PRODUCTS where CLASSICMODELS.PRODUCTS.PRODUCTLINE = CLASSICMODELS.PRODUCTLINES.PRODUCTLINE"; > private static int i = 0; > public static void main( String[] args ) > { > > try { > Class.forName(driverClass); > Connection c = DriverManager.getConnection(driverURL, user, ""); > PreparedStatement s = c.prepareStatement(squery); > c.setAutoCommit(false); > ResultSet r = s.executeQuery(); > ResultSetMetaData meta = r.getMetaData(); > int count = meta.getColumnCount(); > try{ > while(r.next()) { > r.getString(1); > r.getString(2); > Clob clob = r.getClob(3); > // byte[] b = new byte[(int)clob.length()]; > // InputStream stream = clob.getAsciiStream(); > // stream.read(b); > // stream.close(); > // Reader reader = clob.getCharacterStream(); > // reader.read(b); > // reader.close(); > System.out.println( r.getBlob(4)); > > System.out.println( "row count=" + i); > i++; > }}catch( SQLException ex) > { > ex.printStackTrace(); > } > s.close(); > } > catch(Exception e) > { > e.printStackTrace(); > } > > } > } > but when i read after get the CLOB,source code as below: > import java.io.InputStream; > import java.sql.Clob; > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.ResultSetMetaData; > import java.sql.SQLException; > public class Test { > public static String driverClass = "org.apache.derby.jdbc.EmbeddedDriver"; > public static String driverURL = "jdbc:derby:d:\\BirtSample"; > public static String user = "ClassicModels"; > public static String squery = "select * from CLASSICMODELS.PRODUCTLINES,CLASSICMODELS.PRODUCTS where CLASSICMODELS.PRODUCTS.PRODUCTLINE = CLASSICMODELS.PRODUCTLINES.PRODUCTLINE"; > private static int i = 0; > public static void main( String[] args ) > { > > try { > Class.forName(driverClass); > Connection c = DriverManager.getConnection(driverURL, user, ""); > PreparedStatement s = c.prepareStatement(squery); > c.setAutoCommit(false); > ResultSet r = s.executeQuery(); > ResultSetMetaData meta = r.getMetaData(); > int count = meta.getColumnCount(); > try{ > while(r.next()) { > r.getString(1); > r.getString(2); > Clob clob = r.getClob(3); > byte[] b = new byte[(int)clob.length()]; > InputStream stream = clob.getAsciiStream(); > stream.read(b); > stream.close(); > // Reader reader = clob.getCharacterStream(); > // reader.read(b); > // reader.close(); > System.out.println( r.getBlob(4)); > > System.out.println( "row count=" + i); > i++; > }}catch( SQLException ex) > { > ex.printStackTrace(); > } > s.close(); > } > catch(Exception e) > { > e.printStackTrace(); > } > > } > } > the SQLException is thrown when get the row 89,error info as below: > ... > org.apache.derby.impl.jdbc.EmbedBlob@a9255c > row count=89 > java.sql.SQLException: The data in this BLOB or CLOB is no longer available. The BLOB/CLOB's transaction may be committed, or its connection is closed. > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedResultSet.getBlob(Unknown Source) > at Test.main(Test.java:42) > Caused by: java.sql.SQLException: The data in this BLOB or CLOB is no longer available. The BLOB/CLOB's transaction may be committed, or its connection is closed. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) > ... 8 more > Caused by: ERROR XJ073: The data in this BLOB or CLOB is no longer available. The BLOB/CLOB's transaction may be committed, or its connection is closed. > at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedBlob.(Unknown Source) > ... 2 more > when i try to this test on oracle ,this problem will not happen,so i think maybe this is a bug of Derby > your help will be highly apperaciated -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira