Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 21434 invoked from network); 16 Feb 2010 19:52:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Feb 2010 19:52:21 -0000 Received: (qmail 39833 invoked by uid 500); 16 Feb 2010 19:52:21 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 39813 invoked by uid 500); 16 Feb 2010 19:52:20 -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 39805 invoked by uid 99); 16 Feb 2010 19:52:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 19:52:20 +0000 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.21] (HELO gmp-eb-inf-1.sun.com) (192.18.6.21) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Feb 2010 19:52:10 +0000 Received: from fe-emea-09.sun.com (gmp-eb-lb-1-fe1.eu.sun.com [192.18.6.7] (may be forged)) by gmp-eb-inf-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o1GJpopu010013 for ; Tue, 16 Feb 2010 19:51:50 GMT MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) id <0KXY000009S2RJ00@fe-emea-09.sun.com> for derby-dev@db.apache.org; Tue, 16 Feb 2010 19:51:44 +0000 (GMT) Received: from khepri23.norway.sun.com ([unknown] [129.159.112.235]) by fe-emea-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) with ESMTPSA id <0KXY004899U2Y920@fe-emea-09.sun.com> for derby-dev@db.apache.org; Tue, 16 Feb 2010 19:51:38 +0000 (GMT) Date: Tue, 16 Feb 2010 20:51:38 +0100 From: Dag.Wanvik@Sun.COM (Dag H. Wanvik) Subject: Re: Inserting large LOB as a stream... In-reply-to: Sender: Dag.Wanvik@Sun.COM To: derby-dev@db.apache.org Message-id: References: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org Mamta Satoor writes: > Hi, > > I am working on writing a test for INSERT statement which will cause > INSERT trigger to fire. The INSERT is being done into a table with a > large BLOB column. The table definition looks as follows create table > table1 (id int, status smallint, bl blob(2G)) > > My goal is to run this INSERT statement inside a java program with a > limited heap to see if I will run into any OOMs during trigger > execution because we are trying to stream the data into memory. The > way I am trying to insert large LOB is as follows > System.out.println("Inserting into table1 to cause insert trigger to fire"); > PreparedStatement ps = conn.prepareStatement( > "insert into table1(id, status, bl) values(101, 0, ?)"); > byte[] arr = new byte[300000*1024]; > for (int i = 0; i < arr.length; i++) > arr[i] = (byte)4; > ps.setBinaryStream(1, new ByteArrayInputStream(arr), arr.length); > ps.executeUpdate(); > conn.commit(); > But the above code runs into OOM for byte[] arr = new > byte[300000*1024]; because I do not have enough heap available. I was > wondering if there was a way for me to use a stream to insert a pretty > large LOB into my table without having a physical file on the disk > from which I will stream the data in. I do not care about the actual > data. As shown above, I am just inserting a large quantity of (byte)4 > in the LOB. Would appreciate if anyone knows of a way for me to stream > large data into LOB while running with limited heap. You might use the same method as used in BlobMemTest, perhaps? (LoopingAlphabetStream). Thanks, Dag