简体   繁体   中英

Data truncation: Incorrect datetime value: '

Found below error in my program:

Data truncation: Incorrect datetime value: ''

Model Class :

import java.util.Date;

private Date dob;

DaoImpl Class :

String dt = new SimpleDateFormat("dd-MM-yyyy").format(sm.getDob());
Date dob = Date.valueOf(dt);
ps.setDate(5, dob);

Main Controller Class :

sm.setDob(dob.getDate());

preparedStatement accept java.sql.Date :

Date dob = Date.valueOf(dt);   
java.sql.Date sqlDate = new Date(dob.getTime());
ps.setDate(5, sqlDate );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM