title: DateTime is not inserting into the database using jsp
body: <p>I am using jsp file and mysql. I have problem inserting date and time into my database. I can insert the other information but only the date&amp;time. I need to insert the date and time into my database too. How can I achieve it? Any help is appreciated.</p>
  
  <p><strong>Jsp Code</strong></p>
  
  <pre><code> &lt;% 
              String userId       = request.getParameter("UserID");
              String arm          = request.getParameter("Arm");
              String[] armNumber  = request.getParameterValues("ArmNumber");
              String remark       = request.getParameter("Remark");
              String Timestamp    = request.getParameter("Time");
  
  
              out.println("&lt;tr&gt;");
              out.println("&lt;td style='width: 10%'&gt;");
              out.println(Timestamp);
              out.println("&lt;/td&gt;");
              out.println("&lt;/tr&gt;");
  
  
              int count           =0;
              Connection conn     = null;
              try {
                  Class.forName("com.mysql.jdbc.Driver");
                  String connURL = "jdbc:mysql://localhost/Dodo?user=Dodo&amp;password=0000";
                  conn = DriverManager.getConnection(connURL);
  
                  if (armNumber != null){
  
                  for(int i=0; i&lt;armNumber.length; i++){
  
                          String sql="Insert into assign(UserID, Arm, ArmNumber, Remark, Time) Values(?,?,?,?,now())";
                          PreparedStatement pstmt=conn.prepareStatement(sql);
  
                          pstmt.setString (1,userId);
                          pstmt.setString (2,arm);
                          pstmt.setString (3,(armNumber[i]));
                          pstmt.setString (4,remark);
  
                      int rec=pstmt.executeUpdate();
  
                      if (rec==1)
                          count++;
                      }
                  }
      %&gt;
  
  
              &lt;form action="assign.jsp" method="post"&gt;
                  &lt;label&gt;&lt;%=count%&gt; assigned!!&lt;/label&gt;
                  &lt;td style width="50%"&gt;
                  &lt;p&gt;&lt;input type="submit" value="Return" name="ReturnBtn" /&gt;&lt;/p&gt;
              &lt;/form&gt;
  
  
      &lt;%
              conn.close();
              }
              catch(Exception e){
                  e.printStackTrace();
              }
              finally{
  
              }
      %&gt;
  </code></pre>