SourceForge has been redesigned. Learn more.
Close

#191 TimestampTest failures under JDK 1.3

closed
Other (154)
5
2012-08-15
2004-08-03
No

Some of the tests in TimestampTest are failing when run
under JDK 1.3. It looks like a rounding issue (perhaps
with this JDK's JDBC implementation?).

The same tests work fine under JDK 1.4.

Tested using JDK 1.3.1_12 and J2SDK 1.4.1_01 on Windows XP.

Discussion

  • David D. Kilzer

    David D. Kilzer - 2004-08-03

    Logged In: YES
    user_id=84089

    BTW, this occurs against 0.9-alpha1 (0.9-cvs) as of today
    (Tue, Aug 03, 2004).

     
  • Jacek Zadrąg

    Jacek Zadrąg - 2004-08-05

    Logged In: YES
    user_id=577098

    I believe this problem might be caused by a blind cast to
    java.sql.Timestamp from different type of Object. Lines
    starting from 2666 in Tds.java look like this:


    if (!Driver.JDBC3) {
    // Not Running under 1.4 so need to add
    milliseconds
    cal.set(Calendar.MILLISECOND,
    ((java.sql.Timestamp) value).getNanos
    () / 1000000);
    }

    when it really should look like this:

    if (!Driver.JDBC3) {
    // Not Running under 1.4 so need to add
    milliseconds
    if(value instanceof java.sql.Timestamp)
    cal.set(Calendar.MILLISECOND,
    ((java.sql.Timestamp) value).getNanos
    () / 1000000);
    }

    I've fixed jTds ver 0.8.1 like this and it works fine under JDK
    1.3.

     
  • Mike Hutchinson

    Mike Hutchinson - 2004-08-06

    Logged In: YES
    user_id=641437

    It is certainly the case that the code should check that the
    class is actually java.sql.Timestamp before casting the
    object. Failure to do so will cause a ClassCastException;
    however I dont think this is actually the cause of the test
    failure.
    For example, TimestampTest.testDatetimeRounding1() fails at
    the line
    assertEquals(receiveValue.getTime().getTime
    (),rs.getTimestamp(1).getTime()).
    This fails because Timestamp.getTime() does not add the
    nano second component in JDK 1.3. This is after all the
    purpose of the code highlighted in the bug report. To ensure
    that the test works in java 1.3 one needs to amend the code
    to read:
    assertEquals(receiveValue.getTime().getTime(),
    rs.getTimestamp(1).getTime() + rs.getTimestamp(1).getNanos
    () / 1000000);

    Mike.

     
  • Brian Heineman

    Brian Heineman - 2004-08-21

    Logged In: YES
    user_id=716174

    David,

    Mike has submitted a patch that corrects this problem. See:
    https://sourceforge.net/tracker/index.php?
    func=detail&aid=1013432&group_id=33291&atid=407764

    -Brian

     

Log in to post a comment.