Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 51434 invoked from network); 5 Jul 2006 00:18:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Jul 2006 00:18:04 -0000 Received: (qmail 98906 invoked by uid 500); 5 Jul 2006 00:18:03 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 98872 invoked by uid 500); 5 Jul 2006 00:18:02 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 98857 invoked by uid 99); 5 Jul 2006 00:18:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 17:18:02 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.1.36] (HELO gmpea-pix-1.sun.com) (192.18.1.36) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jul 2006 17:18:00 -0700 Received: from d1-emea-03.sun.com ([192.18.2.113]) by gmpea-pix-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id k650HZBa012932 for ; Wed, 5 Jul 2006 01:17:39 +0100 (BST) Received: from conversion-daemon.d1-emea-03.sun.com by d1-emea-03.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0J1W00D01M5ALZ00@d1-emea-03.sun.com> (original mail from Kristian.Waagan@Sun.COM) for derby-user@db.apache.org; Wed, 05 Jul 2006 01:17:34 +0100 (BST) Received: from [192.168.1.100] ([62.16.233.239]) by d1-emea-03.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0J1W00BAOM599424@d1-emea-03.sun.com> for derby-user@db.apache.org; Wed, 05 Jul 2006 01:17:34 +0100 (BST) Date: Wed, 05 Jul 2006 02:17:32 +0200 From: Kristian Waagan Subject: Re: saving zipped CLOB raises a "A truncation error" In-reply-to: <1b4364400607041425t5ffd01e4mdcf22495a06718ca@mail.gmail.com> Sender: Kristian.Waagan@Sun.COM To: Derby Discussion Message-id: <44AB051C.9050400@Sun.COM> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT X-Enigmail-Version: 0.94.0.0 References: <1b4364400607041359q7fa4592die094e257b96a875f@mail.gmail.com> <1b4364400607041425t5ffd01e4mdcf22495a06718ca@mail.gmail.com> User-Agent: Thunderbird 1.5.0.4 (X11/20060617) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Leonardo Kenji Shikida wrote: > then I tried to change it to a BLOB, inserting byte[] > > and I've got > > Exception in thread "main" org.apache.derby.client.am.SqlException: A > truncation error was encountered trying to shrink BLOB 'XX-RESOLVE-XX' > to length 1048576. > at org.apache.derby.client.am.Statement.completeExecute(Unknown Source) > at > org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown > Source) > at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown > Source) > at org.apache.derby.client.net.StatementReply.readExecute(Unknown > Source) > at > org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown > Source) > at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown > Source) > at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown > Source) > at org.apache.derby.client.am.PreparedStatement.executeX(Unknown > Source) > at org.apache.derby.client.am.PreparedStatement.execute(Unknown Source) > at > org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168) > > at > org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168) > > > > any ideas? Hello Kenji, How do you define your CLOB/BLOB column and how big is your data? I can see from the error message that the column is restricted to 1 M (1*1024*1024 = 1048576 bytes) of data. This is the *default* LOB size in earlier versions of Derby. It has now been changed to 2 GB. If Derby receives more data than can fit into a CLOB column, it will try to truncate it by removing trailing whitespace. If this is not possible, it will fail the way your stacktraces are describing. I suggest you try to specify a larger maximum size for your CLOB/BLOB column. Note that 2 GB is the maximum size of LOBs. If you don't know how big your data can get, it is safe to specify the largest possible limit for the column. There are some issues with large LOBs and out-of-memory exceptions, but these are being worked on. Please let us know how if you sort out your problem, or ask questions if you get stuck! Regards, -- Kristian > > [] > > Kenji > > On 7/4/06, Leonardo Kenji Shikida wrote: >> I am trying to store a zipped string into a CLOB column, just like this >> >> String compressedMatrix = >> ZipUtils.compress(matrix.getBuffer().toString()); >> pstmt.setString(2,compressedMatrix); >> >> where ZipUtils is >> >> public static String compress(String is) throws Exception{ >> ByteArrayInputStream bais = new >> ByteArrayInputStream(is.getBytes()); >> ByteArrayOutputStream baos = new >> ByteArrayOutputStream(); >> compress(baos,bais); >> byte[] xx = baos.toByteArray(); >> return new String(xx); >> } >> public static void compress(OutputStream os, InputStream is) >> throws Exception{ >> byte[] buf = new byte[1024]; >> ZipOutputStream out = new ZipOutputStream(os); >> out.putNextEntry(new ZipEntry("compressed")); >> int len; >> while ((len = is.read(buf)) > 0) { >> out.write(buf, 0, len); >> } >> out.close(); >> is.close(); >> out.close(); >> } >> >> but I am getting this exception >> >> Exception in thread "main" org.apache.derby.client.am.SqlException: A >> truncation error was encountered trying to shrink CLOB 'PK' to >> length >> >> at >> org.apache.derby.client.am.Statement.completeExecute(Unknown Source) >> at >> org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown >> Source) >> at >> org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source) >> at >> org.apache.derby.client.net.StatementReply.readExecute(Unknown Source) >> at >> org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown >> Source) >> at >> org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source) >> at >> org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source) >> at >> org.apache.derby.client.am.PreparedStatement.executeX(Unknown Source) >> at >> org.apache.derby.client.am.PreparedStatement.execute(Unknown Source) >> >> I suppose that I don't have to specify charsets because it's assuming >> it's the default one (UTF-8) >> >> Any ideas? Invalid chars? In a CLOB column? >> >> [] >> >> Kenji >> _______________________ >> http://kenjiria.blogspot.com >> http://gaitabh.blogspot.com >> > >