我正在尝试在以时间戳作为列值的表中插入新行。以下是我的代码:
long millisecs = System.currentTimeMillis() ;
Timestamp ts = new java.sql.Timestamp(millisecs) ;
s.executeUpdate("INSERT INTO tblPublicHols(Date) VALUES("+ts+")");
我还尝试使用 PreparedStatment 进行如下操作:
long millisecs = System.currentTimeMillis() ;
Timestamp ts = new java.sql.Timestamp(millisecs) ;
PreparedStatement pstmt ;
pstmt = conn.prepareStatement("INSERT INTO tblBasicHoliday " +
"(Date, RegionID) " +
"VALUES (?, ?)") ;
pstmt.clearParameters() ;
pstmt.setTimestamp(1, ts);
pstmt.setInt(2, 1);
int count = 0 ;
count = pstmt.executeUpdate() ;
我仍然收到相同的错误,如下所示
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
谁能帮我解决这个问题?谢谢。