title: I dono what is the error in my RegController . It does not insert Values in to my Mysql database
body: <p>This is my Register.jsp code. I am creating a student portal information project . When i try to register it accepts the values and also assign it to the variables in the RegController servlet but it is not inserted in to Mysql database . </p>
  
  <pre><code>   &lt;%-- 
      Document   : Register
      Created on : Apr 23, 2014, 11:54:12 PM
      Author     : hari
  --%&gt;
  
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Register Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form method="post" name="register" action="RegController"&gt;
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Email&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="Username" size="15" placeholder="Enter the Username" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Name&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="name" size="15" placeholder="Enter the Name" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Father Name&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="fathername" size="15" placeholder="Enter the Father Name" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Age&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="age" size="5" placeholder="Enter Your Age" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Address&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="address" size="15" placeholder="Enter the Address" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Contact&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="contact" size="15" placeholder="Enter the Contact" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Department&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="dept" size="8" placeholder="Enter the Department" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Qualification&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="qualification" size="15" placeholder="Enter the Qualification" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;College&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="college" size="50" placeholder="Enter the College Name" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Password&lt;/td&gt;
                      &lt;td&gt;&lt;input type="password" name="Password" size="15" placeholder="Enter the Password" required="required"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;input type="submit" name="submit" value="Register"&gt;&lt;/td&gt;
                      &lt;td&gt;To Login&lt;a href="index.jsp"&gt;Click here&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This my Servlet Code RegController.java</p>
  
  <pre><code>import java.sql.*;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.lang.*;
  import static java.lang.System.out;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   *
   * @author hari
   */
  @WebServlet(name = "RegController", urlPatterns = {"/RegController"})
  public class RegController extends HttpServlet {
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          PrintWriter out = response.getWriter();
          String name=request.getParameter("name");
          //out.println("name"+name);
          String Username=request.getParameter("Username");
          String age=request.getParameter("age");
          String fathername=request.getParameter("fathername");
          String address=request.getParameter("address");
          String phno=request.getParameter("contact");
          String dept=request.getParameter("dept");
          String qualification=request.getParameter("qualification");
          String college=request.getParameter("college");
          String Password=request.getParameter("Password");
  
         String DB_url="jdbc:mysql://localhost:3306/MYFIRSTPROJECT";
         String JDBC_Driver="com.mysql.jdbc.Driver";
         String UserDB="root" ;
         String PassDB="";
          int i=1;
          Connection conn=null;
          PreparedStatement pstmt=null;
          //Statement stmt=null;
          try{
          Class.forName("com.mysql.jdbc.Driver");
          //out.println("Connection");
          conn=DriverManager.getConnection(DB_url,UserDB,PassDB);
          String sql="insert into users VALUES(?,?,?,?,?,?,?,?,?,?)";
          //stmt=conn.createStatement();
          pstmt = conn.prepareStatement(sql);
  
          pstmt.setString(1,Username);
          //stmt.executeUpdate(sql);
          pstmt.setString(2,Password);
          pstmt.setString(3,name);
          pstmt.setString(4,fathername);
          pstmt.setString(5,address);
          pstmt.setString(6,age);
          pstmt.setString(7,phno);
          pstmt.setString(8,dept);
          pstmt.setString(9,qualification);
          pstmt.setString(10,college);
          pstmt.executeUpdate();
          pstmt.close();
          //conn.close();
          }
          catch(SQLException se){
          se.printStackTrace();
          } catch (ClassNotFoundException ex) {
              ex.printStackTrace();
          }
          finally{
          try{
          if(pstmt!=null)
              pstmt.close();
          }catch(SQLException se){}
          try{
          if(conn!=null)
              conn.close();
          }catch(SQLException se){se.printStackTrace();}
  
          }
          //if(i&lt;=1){
            //  out.println("Error"+i+Username);}
          //else{
              System.out.println("Registered Successfully");
              response.sendRedirect("Welcome.jsp");
          //}
      }   
  
  }
  </code></pre>
  
  <p>Netbeans doesn't show any errors . Can anybody help plzzz.... </p>