db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinesh Bajaj <dinesh.ba...@ymail.com>
Subject Re: 'ERROR 40XD0: Container has been closed.: java.io.IOException'.
Date Tue, 16 Feb 2010 17:32:52 GMT
I used ByteArrayOutputStream as you suggested, and the problem vanished. Thank you!!

-Dinesh

--- On Tue, 16/2/10, Dinesh Bajaj <dinesh.bajaj@ymail.com> wrote:

From: Dinesh Bajaj <dinesh.bajaj@ymail.com>
Subject: Re: 'ERROR 40XD0: Container has been closed.: java.io.IOException'.
To: "Derby Discussion" <derby-user@db.apache.org>
Date: Tuesday, 16 February, 2010, 10:16 AM


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 <bpendleton@amberpoint.com> wrote:

From: Bryan Pendleton <bpendleton@amberpoint.com>
Subject: Re: 'ERROR 40XD0: Container has been closed.: java.io.IOException'.
To: "Derby Discussion" <derby-user@db.apache.org>
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.


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