db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob
Date Mon, 04 Oct 2010 13:38:35 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917600#action_12917600

Kristian Waagan commented on DERBY-4830:

I think I understand what's going on.
Here's the code with the issue:

			callback.acceptDocumentContent(documentid, dv,
					rs.getCharacterStream(1), /*
											 * rs.getClob(1).getCharacterStream()
											 * ,

Consulting the Java API documentation for for instance ResultSet.getCharacterStream(), note
the following excerpt:
"Note: All the data in the returned stream must be read prior to getting the value of any
other column. The next call to a getter method implicitly closes the stream."

So, when rs.getBinaryStream(3) is executed, the stream returned by rs.getCharacterStream(1)
is implicitly closed.
This doesn't happen if you use rs.getClob(1).getCharacterStream(), because a [BC]lob object
will survive until the transaction is committed/aborted (in the case of auto-commit, until
rs.next() I think).

My take on this is that it is not a Derby bug, but rather a consequence of the JDBC specification.

I guess you have several options to solve this (with different pros/cons):
 o pass the ResultSet and the corresponding column indexes to the acceptDocumentContent method
 o pass a Clob/Blob to the acceptDocumentContent method
 o use the current "work-around", passing streams obtained from the [BC]lob objects

I plan to resolve this issue as invalid. Please let me know if you agree with my analysis.

> ResultSet.getCharacterStream returns closed stream for clob
> -----------------------------------------------------------
>                 Key: DERBY-4830
>                 URL: https://issues.apache.org/jira/browse/DERBY-4830
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions:
>            Reporter: Benson Margulies
>            Priority: Minor
>         Attachments: derby-4830.tar.gz
> After selecting a clob, the following works:
> {code}
>  rs.getClob(1).getCharacterStream()
> {code}
> However, simply calling
> {code}
> rs.getCharacterStream(1)
> {code}
> returns a closed StringReader.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message