Derby
  1. Derby
  2. DERBY-253

Client should throw not implemented exception for depricated setUnicodeStream/getUnicodeStream

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.1.1.0
    • Fix Version/s: 10.2.1.6
    • Component/s: JDBC, Network Client
    • Labels:
      None
    • Issue & fix info:
      Release Note Needed

      Description

      setUnicodeStream and getUnicodeStream are deprecated API's

      Network client
      PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream() should throw not implemented exceptions rather than trying to handle these calls.

      Note: The current client implementation of setUnicodeStream() and getUnicodeStream() are broken and can cause unexpected errors

      1. derby253.diff
        30 kB
        Olav Sandstaa

        Issue Links

          Activity

          Hide
          Olav Sandstaa added a comment -

          I have had some problems trying to reproduce this problem based on the description given in the Jira report.

          The report refers to the a test named "conn/blobclob4BLOB.java", but I am unable to locate any test with name. There is a test named "jdbcapi/blobclob4BLOB.java" and initially I thought this was the right test to use, but I can not find that this test is doing any calls to setUnicodeStream/getUnicodeStream.

          There is a test called "jdbcapi/parameterMapping.java" that does a lot of calls to setUnicodeStream/getUnicodeStream which are disabled when running with the network client. I suspect this is the right test to use for reproducing this problem.

          Since I am new to the Derby code and test harness I would appreciate that someone told me if I am on the wrong track to reproduce this problem.

          Show
          Olav Sandstaa added a comment - I have had some problems trying to reproduce this problem based on the description given in the Jira report. The report refers to the a test named "conn/blobclob4BLOB.java", but I am unable to locate any test with name. There is a test named "jdbcapi/blobclob4BLOB.java" and initially I thought this was the right test to use, but I can not find that this test is doing any calls to setUnicodeStream/getUnicodeStream. There is a test called "jdbcapi/parameterMapping.java" that does a lot of calls to setUnicodeStream/getUnicodeStream which are disabled when running with the network client. I suspect this is the right test to use for reproducing this problem. Since I am new to the Derby code and test harness I would appreciate that someone told me if I am on the wrong track to reproduce this problem.
          Hide
          Kathey Marsden added a comment -

          Removing out of date test information to clarify the Jira entry.

          Show
          Kathey Marsden added a comment - Removing out of date test information to clarify the Jira entry.
          Hide
          Lance Andersen added a comment -

          If you are not going to implement this feature, it should throw a SQLException per section 6.2 of the JDBC 3.0 spec (same requirement in JDBC 4 though we are considering adding a new non-transient SQLException as there appears to be a SQLState that we can use... this is under discussion)

          Show
          Lance Andersen added a comment - If you are not going to implement this feature, it should throw a SQLException per section 6.2 of the JDBC 3.0 spec (same requirement in JDBC 4 though we are considering adding a new non-transient SQLException as there appears to be a SQLState that we can use... this is under discussion)
          Hide
          Olav Sandstaa added a comment -

          This patch replaces the existing implementation of setUnicodeStream and getUnicodeStream in the client driver to just throw a SQL exception with SQL state equal to feature not implemented.

          The following files are changed:

          M java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMapping.out
          M java/client/org/apache/derby/client/am/PreparedStatement.java
          M java/client/org/apache/derby/client/am/ResultSet.java

          The patch is ready for review and commit.

          Show
          Olav Sandstaa added a comment - This patch replaces the existing implementation of setUnicodeStream and getUnicodeStream in the client driver to just throw a SQL exception with SQL state equal to feature not implemented. The following files are changed: M java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMapping.out M java/client/org/apache/derby/client/am/PreparedStatement.java M java/client/org/apache/derby/client/am/ResultSet.java The patch is ready for review and commit.
          Hide
          Knut Anders Hatlen added a comment -

          The patch looks good. I will run some tests and commit it.

          Show
          Knut Anders Hatlen added a comment - The patch looks good. I will run some tests and commit it.
          Hide
          Knut Anders Hatlen added a comment -

          The tests ran cleanly. Committed revision 421570. Thanks Olav!

          Show
          Knut Anders Hatlen added a comment - The tests ran cleanly. Committed revision 421570. Thanks Olav!
          Hide
          Olav Sandstaa added a comment -

          Thanks for reviewing and committing this patch, Knut Anders!

          Since this patch removes functionality from the client driver (although probably broken functionality), is this something that needs a comment in the release notes?

          Show
          Olav Sandstaa added a comment - Thanks for reviewing and committing this patch, Knut Anders! Since this patch removes functionality from the client driver (although probably broken functionality), is this something that needs a comment in the release notes?
          Hide
          Olav Sandstaa added a comment -

          Verified that the patch is in. Thanks for commiting it, Knut Anders!

          Show
          Olav Sandstaa added a comment - Verified that the patch is in. Thanks for commiting it, Knut Anders!
          Hide
          Knut Anders Hatlen added a comment -

          Yes, I think we should mention this in the release notes. Here's my proposal:

          PROBLEM

          PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream()
          throw SQLException when invoked after upgrading to Apache Derby 10.2.

          SYMPTOM

          Calling either of these methods will result in an exception with
          SQLSTATE 0A000 and message: "Feature not implemented: ..."

          CAUSE

          PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream()
          have been deprecated since JDBC 2.0. Derby's implemetation of these
          methods was broken, and it was decided that the methods should throw a
          not-implemented exception instead of being fixed.

          SOLUTION

          This was an intentional change. No Derby product solution is offered.

          WORKAROUND

          Use setCharacterStream() and getCharacterStream() instead of
          setUnicodeStream() and getUnicodeStream().

          Show
          Knut Anders Hatlen added a comment - Yes, I think we should mention this in the release notes. Here's my proposal: PROBLEM PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream() throw SQLException when invoked after upgrading to Apache Derby 10.2. SYMPTOM Calling either of these methods will result in an exception with SQLSTATE 0A000 and message: "Feature not implemented: ..." CAUSE PreparedStatement.setUnicodeStream() and ResultSet.getUnicodeStream() have been deprecated since JDBC 2.0. Derby's implemetation of these methods was broken, and it was decided that the methods should throw a not-implemented exception instead of being fixed. SOLUTION This was an intentional change. No Derby product solution is offered. WORKAROUND Use setCharacterStream() and getCharacterStream() instead of setUnicodeStream() and getUnicodeStream().
          Hide
          Olav Sandstaa added a comment -

          Knut Anders, thanks for the proposal to release notes. This looks very good.

          Show
          Olav Sandstaa added a comment - Knut Anders, thanks for the proposal to release notes. This looks very good.

            People

            • Assignee:
              Olav Sandstaa
              Reporter:
              Kathey Marsden
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development