Hi i’m trying to insert a Date via Servlet in SQL database. If the post submitted field birthday is emtpy then it should insert 0000-00-00
but this is a bit complicated.
i did it this way and it works:
if (birthdate == null) {
ps_employee.setInt(4, 0); //ps_employee is my PreparedStatement
} else {
ps_employee.setDate(4, birthdate);
}
birthday is null if the post field has no value. otherwise birthday contains a valid java.sql.date object.
The code above works but it shows a warning in sql : “data for birthday truncated”….
Is there a better way to insert a 0000-00-00 Date ???
thanks for your help..
1 Answer