java.util.Date()报错

 PreparedStatement stm=con.prepareStatement("insert into message values(?,?,?,?,?)");
      stm.setString(1, title);
      stm.setString(2, name);
      stm.setString(4, content);
      stm.setString(5, email);

      stm.setDate(3,java.util.Date());     Java程序中报错:java.util can not be  resolved  to  a  type;

修改如下:  stm.setDate(3,new java.util.Date()); 还是报错,查看报错内容,提示修改如下:

  stm.setDate(3, new java.sql.Date( new java.util.Date().getTime())); 

你可能感兴趣的:(java,sql)