how to store date from datepicker of jsp via servlet in derby database?

code

#1

reservation.jsp

<%@page contentType=“text/html” pageEncoding=“UTF-8”%>

reservation Page
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <!--<link rel="stylesheet" href="/resources/demos/style.css">-->
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    <script>
        $(function () {
            $("#datepicker").datepicker();
        });
    </script>
  <input type="text" class="form-control" name="datepicker" id="datepicker" placeholder="Date" required=""/>
  <input type="text" class="form-control" name="time"  id="timepicker" placeholder="Time" required=""/>

  <select id="party" name="noOfparty" placeholder="Number of Party" class="form-control" required="">
                    <option>Number of Party</option> 
                    <option>1</option>
                    <option>2</option>
                    <option>3</option>
                    <option>4</option>
                    <option>5</option>
                    <option>6</option>
                    <option>7</option>
                    <option>8</option>
                    <option>9</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    <option>13</option>
 </select>

  <button class="btn btn-lg btn-primary btn-block"  name="Submit" value="reserve" type="Submit"> Reserve 
  </button>

ReserveServlet.java

package Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.text.ParseException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ReserveServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

//private static final Date Date = null;
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

   // String dateString = request.getParameter("date");
    //Date Date = request.getParameter("picker");
    
    String date = request.getParameter("datepicker");
    
    //java.text.DateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy");
    java.text.DateFormat format = new java.text.SimpleDateFormat("MM/dd/yyyy");
    try {
        //java.util.Date d = df.parse(Date);
        java.util.Date da = format.parse(date);
    } catch (ParseException ex) {
        //Logger.getLogger(ReserveServlet.class.getName()).log(Level.SEVERE, null, ex);
        System.out.println(ex);
    }
    
    String Time = request.getParameter("time");
    int party = Integer.parseInt(request.getParameter("noOfparty"));

    try {
        Class.forName("org.apache.derby.jdbc.ClientDriver");
        System.out.println("driver loaded");

        Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/test", "test", "test");
        System.out.println("connection success");

        PreparedStatement ps = con.prepareStatement("insert into reserve values(?,?,?)");
        System.out.println("values inserted");

        //ps.setDate(1, Date);
        java.sql.Date da= new java.sql.Date(da.getTime());
        ps.setDate(1, da);
        ps.setString(2, Time);
        ps.setInt(3, party);

        int i = ps.executeUpdate();
        if (i > 0) {
            out.print("Your Table is successfully reserved...");
        }

    } catch (Exception e2) {
        System.out.println(e2);
    }

    out.close();
}

}