Hi Bryan,

Good idea. Having not worked much with streams before, this idea didn't strike 
me, or I was rather unaware about this possibility. I will try to implement 
this, and let you know whether this worked or not.

Thanks,
Dinesh
--- On Tue, 16/2/10, Bryan Pendleton <[email protected]> wrote:

From: Bryan Pendleton <[email protected]>
Subject: Re: 'ERROR 40XD0: Container has been closed.: java.io.IOException'.
To: "Derby Discussion" <[email protected]>
Date: Tuesday, 16 February, 2010, 7:17 AM

>            ResultSet rs = con.createStatement().executeQuery(
>                     "select * from TABLE1");
>            rs.next();
>            InputStream is = rs.getBinaryStream(1);
>                    long length = rs.getBlob(1).length();
>             rs.close();
> 
>             con.setAutoCommit(false);
>             ps = con.prepareStatement("update table1 set photo = ?");
>             ps.setBinaryStream(1, is, length);
>             ps.executeUpdate();

I think it's problematic to try to hold on to the stream after
you've closed the ResultSet.

What happens if you read the stream fully into memory (say, by
copying it into a ByteArrayOutputStream), before closing the
result set, and then use your in-memory byte array to provide
the data for the update into the other table?

thanks,

bryan




      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/

Reply via email to