Hi Guys,
Just wanted to insert my experience into the mix. I came across the
"ERROR 40XD0: Container has been closed.:
java.io.IOException" error intermittently in the following scenario.
I had a BLOB field from which I was storing retreiving files (~100MB). I
encountered the error sometimes and sometimes not. I changed the
implementation to the second example which always works.
Sorry it it doesn't help, but maybe it does. My point is, _maybe_ the
result set is being closed before the result is wholely extracted?
public InputStream readFile(final Long fileId) {
final Connection cx = getCx();
PreparedStatement ps = null;
ResultSet rs = null;
try {
cx.prepareStatement("select FILE_CONTENT from FILES where
FILE_ID=?");
ps.setLong(1, fileId);
rs = ps.executeQuery();
if (rs.next()) {
return rs.getBlob("FILE_CONTENT").getBinaryStream();
} else {
return null;
}
} finally {
release(cx, ps, rs);
}
}
public void openFile(final Long fileId, final FileOpener opener) throws
IOException {
final Connection cx = getCx();
PreparedStatement ps = null;
ResultSet rs = null;
try {
cx.prepareStatement("select FILE_CONTENT from FILES where
FILE_ID=?");
ps.setLong(1, fileId);
rs = ps.executeQuery();
if (rs.next()) {
final InputStream stream = rs.getBlob
("FILE_CONTENT").getBinaryStream();
try {
opener.open(stream);
} finally {
stream.close();
}
} else {
opener.open(null);
}
} finally {
release(cx, ps, rs);
}
}
On 4/13/07, Ruben Fonseca <[EMAIL PROTECTED]> wrote:
On Fri, 2007-04-13 at 08:38 -0700, Bryan Pendleton wrote:
> > New trace :)
>
> Thanks Ruben!
>
> But we still don't seem to be getting down to the actual IOException.
Thank you too!
>
> I'm expecting to see a line that says:
>
> java.io.IOException: ...
>
> with the actual information and the actual stack trace of the
> IOException itself, but so far all we've seen is the wrapping
> SQLException instances.
Didn't the error "ERROR 40XD0: Container has been closed.:
java.io.IOException" helped? I found a lot of interesting things on this
error on Google. It seems I'm not the only one with this problem.
>
> I suspect the information about the root cause is in the IOException
proper.
>
> Did you follow the stack trace all the way to the end (that is,
> until you got a NULL return from getNextException())?
Yes I've copied the code from the link you gave to me.
>
> If you did, perhaps you can bring your code up in a Java debugger
> and set a breakpoint when java.io.IOException is thrown?
Of course I can :) I'm using Eclipse so I breakpoint on both uncaught
IOException and SQLException. Here's the result:
First break on "IOException" stack:
Thread [main] (Suspended (exception IOException))
OverflowInputStream.fillByteHolder() line: not available
OverflowInputStream(BufferedByteHolderInputStream).read() line:
not available
FormatIdInputStream(DataInputStream).readUnsignedByte() line: 271
SQLClob(SQLChar).readExternal(ObjectInput) line: not available
SQLClob(SQLChar).getString() line: not available
EmbedResultSet40(EmbedResultSet).getString(int) line: not
available
DBFile.<init>(int) line: 45
FileClickListener.handleEvent(Event) line: 31
EventTable.sendEvent(Event) line: 66
Tree(Widget).sendEvent(Event) line: 1097
Display.runDeferredEvents() line: 3238
Display.readAndDispatch() line: 2905
Gui.loop() line: 117
Gui.main(String[]) line: 126
Second break on "SQLException" stack:
Thread [main] (Suspended (exception SQLException))
EmbedResultSet40(EmbedResultSet).getString(int) line: not
available
DBFile.<init>(int) line: 45
FileClickListener.handleEvent(Event) line: 31
EventTable.sendEvent(Event) line: 66
Tree(Widget).sendEvent(Event) line: 1097
Display.runDeferredEvents() line: 3238
Display.readAndDispatch() line: 2905
Gui.loop() line: 117
Gui.main(String[]) line: 126
>
> thanks,
>From what I see from the traces it maybe doesn't help... Maybe I've to
attach sources to my JAR's to see the precise line where the exceptions
are happening. You tell me :)
Ruben
--
---------------------------------------------------------
Raymond Kroeker