I would like to insert a java Timestamp into an msaccess database but I am getting an error which is listed below. The ms-access field has been set to a DATE datatype. Any advise would be deeply appreciated. Thanks
Here's my DAO class method:
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();
My DTO method:
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);
}
My Timestamp method:
public Timestamp addTimestamp(){
java.util.Date date= new java.util.Date();
return new Timestamp(date.getTime());
}
Error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.