mysql date || Java web application|| inserts a date in the database using date picker, JSP,MySQL.

How to read the date from a date picker using JSP and servlet and insert the date in the database using JSP and date picker. Jquery make this task easy for me to perform an operation on MySQL date. In this tutorial, we will see how to do that.

Insert a MYSQL date in the database using date picker.

Create a JSP file “index.jsp”

    Document   : index
    Created on : Nov 1, 2017, 4:58:44 PM
    Author     : hp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
        <title>Java Date Picker</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="">
        <script src=""></script>
        <script src=""></script>
            $(function () {

        <form action="DatePicker">
            <label for="datepicker">Enter Your Date of Birth:</label>
                <input type="text" name="dob" id="datepicker">
            <input type="submit" value="Submit">

Create a servlet file “”

Read date from index.jsp and insert into MYSQL database.

try {
                /* TODO output your page here. You may use following sample code. */
                String dob = request.getParameter("dob");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/demo", "root", "root");
               Statement stmt = con.createStatement();
                stmt.executeUpdate("insert into emp(dob) values('"+dob+"')");
                out.println("Your Date of birth "+dob+ " is submited is database");
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(DatePicker.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(DatePicker.class.getName()).log(Level.SEVERE, null, ex);

Note: Remember for creating the connection between Java and MYSQL you need a “mysql-connector” please download or import into your library or watch the video.

Step by Step Tutorial to configure Java project

Viva Questions and answer for java project

Check new projects in java

You May Also Like These Posts:

Leave a Reply

Your email address will not be published.

11 + 5 =