Derby
  1. Derby
  2. DERBY-4949

Backward, confusing error message when you use the wrong ResultSet.getXXX() method in the client driver

    Details

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

      Description

      If you try to get a Time value out of an INTEGER column, the client driver gives this error. I believe that similar nonsense comes back when you try other mismatched getters on other datatypes:

      "An attempt was made to get a data value of type 'java.sql.Types 4' from a data value of type 'java.sql.Time'."

      The exception is a java.sql.SQLDataException with SQLState 22005. The embedded driver returns a better message:

      "An attempt was made to get a data value of type 'java.sql.Time' from a data value of type INTEGER'."

      I recommend two improvements to the utility method which generates these exceptions:

      1) Flip the order of the type names.

      2) Use the ResultSetMetaData to look up the source data type name.

      1. derby-4949-01-aa-fixCursor.diff
        9 kB
        Rick Hillegas
      2. zz.java
        1 kB
        Rick Hillegas

        Activity

        Hide
        Rick Hillegas added a comment -

        Tests passed cleanly except for a heisenbug in NetworkServerMBeanTest. Committed at subversion revision 1052350.

        Show
        Rick Hillegas added a comment - Tests passed cleanly except for a heisenbug in NetworkServerMBeanTest. Committed at subversion revision 1052350.
        Hide
        Rick Hillegas added a comment -

        Attaching derby-4949-01-aa-fixCursor.diff. This is a first attempt to fix this problem. I am running regression tests now and will see what breaks.

        The root cause of the problem was that ColumnTypeConversionException was coded backwards. The names of its arguments should have been flipped to agree with the order of the arguments in the actual message. I have cleaned up the argument names in this class.

        There was a second problem in Cursor. There the coercion errors were passed the weird source type of '"java.sql.Types " + jdbcTypes_[column -1]', which is a pretty cryptic name for a datatype. I have replaced those cryptic type names with human-readable names produced by invoking Types.getTypeString().

        Touches the following files:

        ---------

        M java/client/org/apache/derby/client/am/Cursor.java
        M java/client/org/apache/derby/client/am/SqlException.java

        Show
        Rick Hillegas added a comment - Attaching derby-4949-01-aa-fixCursor.diff. This is a first attempt to fix this problem. I am running regression tests now and will see what breaks. The root cause of the problem was that ColumnTypeConversionException was coded backwards. The names of its arguments should have been flipped to agree with the order of the arguments in the actual message. I have cleaned up the argument names in this class. There was a second problem in Cursor. There the coercion errors were passed the weird source type of '"java.sql.Types " + jdbcTypes_ [column -1] ', which is a pretty cryptic name for a datatype. I have replaced those cryptic type names with human-readable names produced by invoking Types.getTypeString(). Touches the following files: --------- M java/client/org/apache/derby/client/am/Cursor.java M java/client/org/apache/derby/client/am/SqlException.java
        Hide
        Rick Hillegas added a comment -

        Attaching zz.java, a program which shows this problem. You may want to edit the program to change the port number of the server.

        Show
        Rick Hillegas added a comment - Attaching zz.java, a program which shows this problem. You may want to edit the program to change the port number of the server.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development