Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 8712 invoked from network); 17 Jul 2006 13:49:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Jul 2006 13:49:26 -0000 Received: (qmail 78632 invoked by uid 500); 17 Jul 2006 13:49:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 78594 invoked by uid 500); 17 Jul 2006 13:49:25 -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 78585 invoked by uid 99); 17 Jul 2006 13:49:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2006 06:49:25 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2006 06:49:24 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0279571429F for ; Mon, 17 Jul 2006 13:47:18 +0000 (GMT) Message-ID: <2109589.1153144038007.JavaMail.jira@brutus> Date: Mon, 17 Jul 2006 06:47:18 -0700 (PDT) From: "Andreas Korneliussen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-802) OutofMemory Error when reading large blob when statement type is ResultSet.TYPE_SCROLL_INSENSITIVE In-Reply-To: <919640186.1136828092695.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-802?page=3Dall ] Andreas Korneliussen updated DERBY-802: --------------------------------------- Attachment: derby-802v3.diff derby-802v3.stat Attached is a patch (derby-802v3.diff and derby-802v3.stat) which uses proj= ectmappings calculated from ProjectRestrictResultSet, and 4 new testcases w= ith projections has been added to BLOBTest.junit > OutofMemory Error when reading large blob when statement type is ResultSe= t.TYPE_SCROLL_INSENSITIVE > -------------------------------------------------------------------------= ------------------------- > > Key: DERBY-802 > URL: http://issues.apache.org/jira/browse/DERBY-802 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.1.1, 10.1.1.2, 10= .1.2.0, 10.1.2.1, 10.2.0.0, 10.1.3.0, 10.1.2.2, 10.0.2.2 > Environment: all > Reporter: Sunitha Kambhampati > Assigned To: Andreas Korneliussen > Priority: Minor > Attachments: derby-802.diff, derby-802.stat, derby-802v2.diff, de= rby-802v3.diff, derby-802v3.stat > > > Gr=C3=A9goire Dubois on the list reported this problem. From his mail: t= he reproduction is attached below.=20 > When statement type is set to ResultSet.TYPE_SCROLL_INSENSITIVE, outofmem= ory exception is thrown when reading large blobs.=20 > import java.sql.*; > import java.io.*; > /** > * > * @author greg > */ > public class derby_filewrite_fileread { > =20 > private static File file =3D new File("/mnt/BigDisk/Clips/BabyMamaDra= ma-JShin.wmv"); > private static File destinationFile =3D new File("/home/greg/DerbyDat= abase/"+file.getName()); > =20 > /** Creates a new instance of derby_filewrite_fileread */ > public derby_filewrite_fileread() { =20 > =20 > } > =20 > public static void main(String args[]) { > try { > Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInst= ance(); > Connection connection =3D DriverManager.getConnection ("jdbc:= derby:/home/greg/DerbyDatabase/BigFileTestDB;create=3Dtrue", "APP", ""); > connection.setAutoCommit(false); > =20 > Statement statement =3D connection.createStatement(ResultSet.= TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); > ResultSet result =3D statement.executeQuery("SELECT TABLENAME= FROM SYS.SYSTABLES"); > =20 > // Create table if it doesn't already exists. > boolean exist=3Dfalse; > while ( result.next() ) { > if ("db_file".equalsIgnoreCase(result.getString(1))) > exist=3Dtrue; > } > if ( !exist ) { > System.out.println("Create table db_file."); > statement.execute("CREATE TABLE db_file ("+ > " name VARCHAR(40= ),"+ > " file BLOB(2G) N= OT NULL)"); > connection.commit(); > } > =20 > // Read file from disk, write on DB. > System.out.println("1 - Read file from disk, write on DB."); > PreparedStatement preparedStatement=3Dconnection.prepareState= ment("INSERT INTO db_file(name,file) VALUES (?,?)"); > FileInputStream fileInputStream =3D new FileInputStream(file)= ; > preparedStatement.setString(1, file.getName()); > preparedStatement.setBinaryStream(2, fileInputStream, (int)fi= le.length()); =20 > preparedStatement.execute(); > connection.commit(); > System.out.println("2 - END OF Read file from disk, write on = DB."); > =20 > =20 > // Read file from DB, and write on disk. > System.out.println("3 - Read file from DB, and write on disk.= "); > result =3D statement.executeQuery("SELECT file FROM db_file W= HERE name=3D'"+file.getName()+"'"); > byte[] buffer =3D new byte [1024]; > result.next(); > BufferedInputStream inputStream=3Dnew BufferedInputStream= (result.getBinaryStream(1),1024); > FileOutputStream outputStream =3D new FileOutputStream(destin= ationFile); > int readBytes =3D 0; > while (readBytes!=3D-1) { > readBytes=3DinputStream.read(buffer,0,buffer.length); > if ( readBytes !=3D -1 ) > outputStream.write(buffer, 0, readBytes); > } =20 > inputStream.close(); > outputStream.close(); > System.out.println("4 - END OF Read file from DB, and write o= n disk."); > } > catch (Exception e) { > e.printStackTrace(System.err); > } > } > } > It returns > 1 - Read file from disk, write on DB. > 2 - END OF Read file from disk, write on DB. > 3 - Read file from DB, and write on disk. > java.lang.OutOfMemoryError > if the file is ~10MB or more --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira