Archives of the TeradataForum
Message Posted: Mon, 19 Jun 2006 @ 16:13:51 GMT
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
|