db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag.Wan...@Sun.COM (Dag H. Wanvik)
Subject Re: Inserting large LOB as a stream...
Date Tue, 16 Feb 2010 19:51:38 GMT
Mamta Satoor <msatoor@gmail.com> 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

Mime
View raw message