我想在msaccess数据库中插入Java时间戳,但出现以下错误. ms-access字段已设置为DATE数据类型.任何建议将不胜感激.谢谢
这是我的DAO类方法:
public void addSale(String saleDetails, String saleTotal, Timestamp saleTimestamp)
throws ClassNotFoundException, SQLException {
Statement myStatement = getConnection();
String sql = "INSERT INTO Sale (SaleDetails, SaleTotal, SaleTimestamp)"
+ " VALUES ('"+saleDetails+"','"+saleTotal+"','"+saleTimestamp+"')";
myStatement.executeUpdate(sql);
closeConnection();
我的DTO方法:
public void storeSale(String saleDetails, String saleTotal, Timestamp saleTimestamp){
DAO dao = DAO.getDAO();
try {
dao.addSale(saleDetails, saleTotal, saleTimestamp);
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Sale.class.getName()).log(Level.SEVERE, null, ex);
}
我的时间戳方法:
public Timestamp addTimestamp(){
java.util.Date date= new java.util.Date();
return new Timestamp(date.getTime());
}
错误:
????[Microsoft] [ODBC Microsoft Access驱动程序]条件表达式中的数据类型不匹配.