Derby
  1. Derby
  2. DERBY-4890

Different string to boolean conversion on embedded and client

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: JDBC
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Embedded/Client difference

      Description

      The following code fragment behaves differently on client and embedded:

      PreparedStatement ps = c.prepareStatement("values cast(? as boolean)");
      ps.setString(1, "TRUE");
      ResultSet rs = ps.executeQuery();
      rs.next();
      System.out.println(rs.getBoolean(1));

      Embedded prints "true". Client raises an exception:

      Exception in thread "main" java.sql.SQLDataException: An attempt was made to get a data value of type 'VARCHAR' from a data value of type 'BOOLEAN'.
      at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:72)
      at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:358)
      at org.apache.derby.client.am.PreparedStatement.setString(PreparedStatement.java:884)
      at SetByte.main(SetByte.java:6)
      Caused by: org.apache.derby.client.am.SqlException: An attempt was made to get a data value of type 'VARCHAR' from a data value of type 'BOOLEAN'.
      at org.apache.derby.client.am.PreparedStatement$PossibleTypes.throw22005Exception(PreparedStatement.java:3069)
      at org.apache.derby.client.am.PreparedStatement.setString(PreparedStatement.java:874)
      ... 1 more

        Issue Links

          Activity

          Hide
          Knut Anders Hatlen added a comment -

          Verified. Thanks, Rick.

          Show
          Knut Anders Hatlen added a comment - Verified. Thanks, Rick.
          Hide
          Rick Hillegas added a comment -

          Tests passed cleanly for me. Committed at subversion revision 1032780.

          Show
          Rick Hillegas added a comment - Tests passed cleanly for me. Committed at subversion revision 1032780.
          Hide
          Rick Hillegas added a comment -

          Attaching derby-4890-01-aa-setStringBoolean.diff. This patch fixes the bug. I am running tests now.

          BOOLEAN needed to be added to the list of datatypes for which the network setString() method works.

          Touches the following files:

          -------------

          M java/client/org/apache/derby/client/am/PreparedStatement.java

          Added BOOLEAN to the list of datatypes for which setString() works.

          -------------

          M java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

          Added some test cases for this bug and for DERBY-4889.

          -------------

          M java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java

          Removed code recently added to bypass this problem.

          Show
          Rick Hillegas added a comment - Attaching derby-4890-01-aa-setStringBoolean.diff. This patch fixes the bug. I am running tests now. BOOLEAN needed to be added to the list of datatypes for which the network setString() method works. Touches the following files: ------------- M java/client/org/apache/derby/client/am/PreparedStatement.java Added BOOLEAN to the list of datatypes for which setString() works. ------------- M java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java Added some test cases for this bug and for DERBY-4889 . ------------- M java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java Removed code recently added to bypass this problem.
          Hide
          Knut Anders Hatlen added a comment -

          ParameterMappingTest contains two workarounds for this issue. Search for comments with this issue number in the source file.

          Show
          Knut Anders Hatlen added a comment - ParameterMappingTest contains two workarounds for this issue. Search for comments with this issue number in the source file.
          Hide
          Knut Anders Hatlen added a comment -

          Same problem with setObject("TRUE").

          Show
          Knut Anders Hatlen added a comment - Same problem with setObject("TRUE").

            People

            • Assignee:
              Rick Hillegas
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development