1. 程式人生 > >The method setDate(int, java.sql.Date) in the type PreparedStatement is not applicable for the argum

The method setDate(int, java.sql.Date) in the type PreparedStatement is not applicable for the argum

The method setDate(int, java.sql.Date) in the type PreparedStatement is not applicable for the arguments (int, java.util.Date)

preparedStatement.setDate(7, student.getRegdate());

出現這種問題是因為Date的兩個包 java.sql.Date和 java.util.Date不能相容。

preparedStatement.setDate(7,new Date(student.getRegdate().getTime());
只要通過下面的方法進行格式化即可。