Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 19 Jun 2006 @ 16:13:51 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: JDBC (3.2.0.2) problem with Timestamps
 
From:   Nine, Todd

I've found the solution/workaround, and I'm a bit surprised. It seems Teradata's driver will not accept a timestamp that has nanos set. For instance, here is a snippit of code that will fail.

     PreparedStatement ps = conn.prepareStatement("insert into foo values (?,?)");

     Calendar cal = Calendar.getInstance();

     ps.setString(1, "A");

     Timestamp ts = new Timestamp(cal.getTimeInMillis());

     ps.setTimestamp(ts);

     //fails with invalid timestamp
     ps.execute();

Here is a snippit that passes.

     PreparedStatement ps = conn.prepareStatement("insert into foo values (?,?)");

     Calendar cal = Calendar.getInstance();

     ps.setString(1, "A");

     Timestamp ts = new Timestamp(cal.getTimeInMillis());
     //we have to set nanos to 0 or the timestamp insert craps out
     ts.setNanos(0);

     ps.setTimestamp(ts);

     //passes
     ps.execute();

It appears that the driver does not correctly handle the nanos field. If the driver can't utilize nanos, why doesn't it just ignore this property?


Todd



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023