You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Benson Margulies (JIRA)" <ji...@apache.org> on 2010/10/01 23:54:33 UTC

[jira] Created: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

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: 10.6.1.0
            Reporter: Benson Margulies
            Priority: Minor


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.


[jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Benson Margulies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917565#action_12917565 ] 

Benson Margulies commented on DERBY-4830:
-----------------------------------------

It's a memory database. I am using Spring/JDBC 3.0.4. I will endeavour to make an isolated test case for you.

> 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: 10.6.1.0
>            Reporter: Benson Margulies
>            Priority: Minor
>
> 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.


[jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917541#action_12917541 ] 

Kristian Waagan commented on DERBY-4830:
----------------------------------------

Do you have any more details on this?
Is it happening with the embedded driver, the client driver, or both?
Can you easily write some running code that demonstrates the problem?

I'm positive rs.getCharacterStream(1) works in the general case, it would be nice to identify the circumstances that trigger the problem.


Thanks,

> 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: 10.6.1.0
>            Reporter: Benson Margulies
>            Priority: Minor
>
> 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.


[jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
    [ 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()
											 * ,
											 */
					rs.getBinaryStream(3));

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: 10.6.1.0
>            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.


[jira] Closed: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan closed DERBY-4830.
----------------------------------

    Resolution: Not A Problem

Thanks, Benson.
Resolved the issue as 'Not A Problem' and closed it.

> 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: 10.6.1.0
>            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.


[jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Benson Margulies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917606#action_12917606 ] 

Benson Margulies commented on DERBY-4830:
-----------------------------------------

I have no objection to your analysis. It seems to be a very strange aspect of the JDBC set, but there is stiff competition for the title of 'strangest aspect of the JDBC API.' Thank you very much for explaining it to me.

> 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: 10.6.1.0
>            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.


[jira] Commented: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Benson Margulies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917570#action_12917570 ] 

Benson Margulies commented on DERBY-4830:
-----------------------------------------

I've attached code. I did not perform a complete minimization, but I don't think you'll have you much trouble using this to debug.

The test that failes is JDDDaoTest.testReadDocument.

In JDDDao.java, at line 114, the working code is commented out, and the failing code is commented in.



> 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: 10.6.1.0
>            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.


[jira] Updated: (DERBY-4830) ResultSet.getCharacterStream returns closed stream for clob

Posted by "Benson Margulies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benson Margulies updated DERBY-4830:
------------------------------------

    Attachment: derby-4830.tar.gz

Test case.

> 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: 10.6.1.0
>            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.