Hello.
For two days i am fighting a problem when using JPA (toplink) with derby to persist data of my program. One object i persist saves a byte[] into a blob. I looked for oome reports and checked for bug 1693, which was corrected for 10.2.2. I modified its test class in order to check for what should JPA be doing and found that in order to be able to save some 8MB arrays, i need to set java heap to 128MB. Also, if i try to persist objects with multiple 4-6MB arrays, i get oome with 64MB after only a handful of persisted objects.
Is that intended?
Of course, sending data to the database using a stream works, but as far as i could gather, sending the array through a stream during persistence is not possible.
I am using derby 10.2.2, java 1.6.0_01ea

I will be very grateful for any idea on how to solve that.

>snip<------8<----------------------------------------------------------------------------

public class OomeTest
{
   /**
    * DOCUMENT_ME!
    *
    * @param args DOCUMENT_ME!
    *
    * @throws Exception DOCUMENT_ME!
    */
   public static void main( String args[] ) throws Exception
   {
       System.setProperty( "derby.language.logStatementText", "true" );
       Class.forName( "org.apache.derby.jdbc.EmbeddedDriver" );
Connection con = DriverManager.getConnection( "jdbc:derby:ReproDerby1693DB;create=true;" );
       Statement stmt = con.createStatement(  );
// Try to drop the table, then create.
       try
       {
           stmt.executeUpdate( "drop table blobs" );
       }
       catch ( SQLException sqle )
       {
           if ( !sqle.getSQLState(  ).equals( "42Y55" ) )
           {
               throw sqle;
           }
       }
stmt.executeUpdate( "create table blobs (clobData blob)" );
       stmt.close(  );
byte[] buffer = new byte[6000000];// 6MB
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       {
PreparedStatement pStmt = con.prepareStatement( "insert into blobs values (?)" );
           pStmt.setObject( 1, buffer );
           pStmt.executeUpdate(  );
           pStmt.close(  );
           System.out.println( "Success!" );
       }
       con.close(  );
   }
}

Reply via email to