Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6374055

JDBC-ODBC time field regression in latest builds causing runtime exceptions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b67)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b67, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      I'm getting some runtime exceptions (not SQLExceptions!) with JDBC-ODBC in the latest builds of Mustang (build 67), where no such problem exists with Java 5.

      When working with a Microsoft Access database, attempting to retrieve a date value using ResultSet::getObject() consistently fails for in each test environment I've tried.

      Here's the stacktrace:
      java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
      at java.sql.Timestamp.valueOf(Timestamp.java:208)
      at sun.jdbc.odbc.JdbcOdbcResultSet.getTimestamp(JdbcOdbcResultSet.java:1068)
      at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1724)


      ...and here's the code:

      ResultSetMetaData rsmd = rset.getMetaData();
      int columnCount = rsmd.getColumnCount();

      List<String> columnNames = new ArrayList<String>(columnCount);
      List<Object[]> rowData = new ArrayList<Object[]>();

      for (int c = 1; c <= columnCount; c++)
      {
      columnNames.add(rsmd.getColumnName(c));
      }

      while (rset.next())
      {
      Object[] fields = new Object[columnCount];
      for (int c = 1; c <= columnCount; c++)
      {
      Object field = rset.getObject(c);
      if (field instanceof String)
      {
      field = DbAccess.clean((String)field);
      }
      fields[c-1] = field;
      }
      rowData.add(fields);
      }
      rset.close();


      For information, I only stored dates (not times) in these fields, as Access doesn't seem to differentiate "date" fields from "time" fields. Calling ResultSet::getDate() doesn't cause any problems.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a database in Access containing a date/time field (it may contain NULLs). Use PreparedStatement.setDate() or setNull(Types.DATE) to fill some rows. Read it using ResultSet.getDate() and it works. Use ResultSet.getObject() and it doesn't.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The "getDate()" and "getObject()" methods should both be able to read the date value as a java.sql.Date, as it appears to do correctly in Java 5. It should never throw an IllegalArgumentException (and frankly there's no need for an SQLException here either...).
      ACTUAL -
      It worked in Java 5, but in Java 6-rc-b67 it threw an unexpected runtime exception and killed my thread.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
      at java.sql.Timestamp.valueOf(Timestamp.java:208)
      at sun.jdbc.odbc.JdbcOdbcResultSet.getTimestamp(JdbcOdbcResultSet.java:1068)
      at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1724)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See example in description for an idea. You'd need an appropriate database. Hopefully the stacktrace should help identify the problematic code (compare with getDate or the Java 5 equivalent).
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No effective workaround found.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ahandasunw Amit Handa (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: