You need to convert java.util.Date
instance to java.sql.Date
format. and then use it with PreparedStatement.
Change:
pstmt.setDate( 1, d1 );
to:
pstmt.setDate( 1, new java.sql.Date( d1.getTime() );
If the field is of type datetime
or timestamp
, you have to use
pstmt.setTimestamp( 1, new java.sql.Timestamp( d1.getTime() );