You must
use the proper JDBC escape sequence to insert timestamps (keyword
ts
), dates (keyword
d
), and times (keyword
t
). The following
code fragment illustrates using the escape sequence with timestamp.
Timestamp ts = new Timestamp(System.currentTimeMillis());
// By using an escape clause with curly braces and the ts keyword,
// the following code is portable across the SAS Drivers for JDBC.
String myDate = new String ("{ts '" + ts.toString() + "'}");
String query =
"INSERT INTO work.testtable (index, ts, name) VALUES ("
+ i
+ ", "
+ myDate
+ ", "
+ n
+ ")";