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

[inet-oracle ] truncates nanos while saving java.sql timestamp into oracle 9i da

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8.0pe
    • 8.0pe
    • core-libs
    • 8.0pe
    • generic
    • generic
    • Verified

      Filing bug as an issue holder.
      inet oracle driver truncates nanos while saving timestamps into database. Here is a test to reproduce it.


         void timestampTest() throws SQLException {
             // Execute following DDL.
             //create table test (DATATYPESID varchar2(255), TIMESTAMPDATA TIMESTAMP(9) );
             //
                   //Insert Timestamp with nanos set to 23
             PreparedStatement ps = conn.prepareStatement("insert into test (DATATYPESID, TIMESTAMPDATA) values (1, ?)");
             Timestamp ts = new Timestamp(0);
             ts.setNanos(23);
             System.out.println("Saved Timestamp = " + ts);
             ps.setTimestamp(1, ts);
             ps.executeUpdate();
             conn.commit();
                   //Query the timestamp back. It shows nanos as 0. Even in database, the nanos is showed as 0
             ps = conn.prepareStatement("select TIMESTAMPDATA from test where DATATYPESID = '1'");
             ResultSet rs = ps.executeQuery();
             rs.next(); Timestamp retrievedTs = rs.getTimestamp(1);
             System.out.println("Retrieved Timestamp = " + retrievedTs);
         }


      Running with oracle 9 driver, we get following output
      Saved Timestamp = 1969-12-31 16:00:00.000000023
      Retrieved Timestamp = 1969-12-31 16:00:00.000000023

      Running with inet driver, we get following output
      Saved Timestamp = 1969-12-31 16:00:00.000000023
      Retrieved Timestamp = 1969-12-31 16:00:00.0

      ###@###.### 2003-10-08
      ###@###.### 2004-06-16

            lancea Lance Andersen
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: