I have a variable named targetdate
and I would like to insert a value in my form.
In my Controller, I have this:
public static int addStudent(Student studentBean){
int status=0;
try{
Connection con=getConnection();
PreparedStatement ps=con.prepareStatement("insert into students (targetdate) values(?)");
ps.setDate(1,studentBean.getTargetdate());
status=ps.executeUpdate();
}catch(Exception e){System.out.println(e);}
return status;
}
My problem is the line below:
ps.setDate(1,studentBean.getTargetdate());
I have an error message:
the method
setDate(int, java.sql.Date)
in the typepreparedstatement
is not applicable for the argument(int, java.util.Date)
I am beginner in Java, I don't understand the problem.