欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-07-15 13:22:32
...

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

原因: java.sql.Date和 java.util.Date不能兼容
解决方法:

java.util.Date date = sdf.parse(date_s);
pst.setDate(1, date);

转换:

pst.setDate(1, new Date(date.getTime()));
相关标签: mysql java