db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendle...@amberpoint.com>
Subject Re: 'ERROR 40XD0: Container has been closed.: java.io.IOException'.
Date Tue, 16 Feb 2010 01:47:16 GMT
>            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


Mime
View raw message