我需要使用Statement.executeUpdate()
将数据插入数据库。因此,每个参数都必须嵌入到 SQL 字符串中。在数据库中,两列的类型是日期时间: Date1 和 Date2 在客户端,如果我使用以下语句:
String SQLString = "INSERT INTO Position (" +
......
"Date1, " +
......
"Date2) " +
"VALUES(" +
......
//"2012-05-29 16:28:58.555" + ", " + // runtime error, always say error at 16
//"2012-05-29" + ", " + // no runtime error, but lost time and result date is also not correct
//"10-06-02" + ", " + // no runtime error, but it adds 2 days beginning at 1900-01-01 00:00:00.000
......
null
")";
谁能告诉我如何正确地将日期时间嵌入到 SQL 字符串中?