How to update value in jdbc?

I am getting exception java.lang.illegalargumentexception when I try to update the value of date field. I have a SQL database which have 2 timestamp field format (0000-00-00 00:00:00).

Here is my HTML code:

<%=stade%>=2014-01-19 21:43:20.0
<%=edate%>=2014-08-31 01:45:03.0

StartDate</span>
<input type="text" name="sdate" maxlength="25" size="25"id="demo2" value="<%=sdate%>"><a href="javascript:NewCal('demo2','ddmmmyyyy',true,24)"></a>

ExpireDate
<input type="Text" id="demo1" name="edate"maxlength="25" size="25" value="<%=edate%>"><a href="javascript:NewCal('demo1','ddmmmyyyy',true,24)"></a>
                 <

I want that if I donot make any change in these field then actual value of edade and sdate insert otherwise updated value inserted

updade.jsp

<%
    String edate=request.getParameter("edate");
    String sdate=request.getParameter("sdate");

    try
    {
        String s1;
        String s2;
        Format formatter;
        Date d2=new Date(sdate);
        Date d1 = new Date(edate);
        Date date = new Date();
        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        s = formatter.format(date);
        s1 = formatter.format(d1);
        s2=formatter.format(d2);
        out.println("\n"+s1);
        out.println("\n"+s2);
        psmnt= cn.prepareStatement("update Councel set StartDate=?,ExpireDate=? where CouncelRegNo=?");
        psmnt.executeUpdate(); 
        out.println("Student updated successfully");
    }
    catch(Exception e)
    {
        out.print("try not allowed"+e);
    }
%>
Jon Skeet
people
quotationmark

Look at this code:

psmnt= cn.prepareStatement("update Councel set StartDate=?,ExpireDate=? where CouncelRegNo=?");
psmnt.executeUpdate(); 

You're preparing a statement with three parameters, but not setting any of them.

Additionally, I would suggest not treating your timestamps as text - instead, they should be appropriate timestamp/datetime/whatever fields in the database, and you should avoid ever treating them as text. The more string conversions you perform, the more risk there is that you'll mess one of them up.

You should also avoid the Date(String) constructor, which has been deprecated for years.

Oh, and prefer declaring variables at the point of first use, rather than declaring everything up front and then assigning values...

people

See more on this question at Stackoverflow