title: How to debug "java.lang.NumberFormatException: For input string: X" in Java?
body: <p>I am trying to run one program. I am really very new on Java. When I run my program I am getting following exception:</p>
  
  <pre><code>Description: The server encountered an internal error () that prevented it from fulfilling this request.
  
  Exception: java.lang.NumberFormatException: For input string: ""
      java.lang.NumberFormatException.forInputString(Unknown Source)
      java.lang.Integer.parseInt(Unknown Source)
      java.lang.Integer.parseInt(Unknown Source)
      UpdateSearchRecord.doPost(UpdateSearchRecord.java:56)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717
  </code></pre>
  
  <p>Here is my code for your reference:</p>
  
  <pre><code>import java.io.IOException;`
  import java.io.PrintWriter;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  //import java.sql.ResultSet;
  //import java.sql.ResultSetMetaData;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   * Servlet implementation class UpdateSearchRecord
   */
  public class UpdateSearchRecord extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * @see HttpServlet#HttpServlet()
       */
      public UpdateSearchRecord() {
          super();
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      }
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
  
          String uname = request.getParameter("uname");
          String pwd = request.getParameter("pwd");
          String confo = request.getParameter("confo");
          String name = request.getParameter("name");
          String program = request.getParameter("program");
          String country = request.getParameter("country");
          String city = request.getParameter("city");
          String state = request.getParameter("state");
          int pin = Integer.parseInt(request.getParameter("pin"));
          int contact = Integer.parseInt(request.getParameter("contact"));
          String address = request.getParameter("address");
          String idd = request.getParameter("id");
          int id = Integer.parseInt(idd);
  
          int confor = 0;
  
  
          if(uname.equals("") 
              || pwd.equals("") 
              || confo.equals("") 
              || name.equals("") 
              || program.equals("") 
              || country.equals("") 
              || city.equals("") 
              || state.equals("") 
              || address.equals("")){
  
              out.println("Please insert valid data");
              out.println("&lt;input type=\"text\" value=\"confo\" " + "name=\"confor\"&gt;");
              RequestDispatcher rd = request.getRequestDispatcher("UpdateRecord");
              rd.forward(request, response);
  
          } else {
              confor=Integer.parseInt(confo);
              try {
                  Class.forName("oracle.jdbc.driver.OracleDriver");
                  Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","sayam");
  
                  PreparedStatement ps=con.prepareStatement(
  "UPDATE SP SET uname=?,pwd=?, confo=?,name=?,program=?, country=?,city=?,state=?,pin=?,contact=?,address=? where id=? ");
  
                  ps.setInt(12,id);
                  ps.setString(1,uname); 
                  ps.setString(2,pwd);
                  ps.setInt(3,confor);
                  ps.setString(4,name);
                  ps.setString(5,program);
                  ps.setString(6,country);
                  ps.setString(7,city);
                  ps.setString(8,state);
                  ps.setInt(9,pin);
                  ps.setInt(10,contact);
                  ps.setString(11,address);
                  //ps.setInt(12,id);
  
                  int i=ps.executeUpdate();
                  if(i &gt; 0) {
                      out.print("Record successfully Updated");
                  }
              } catch (Exception e) {
                  System.out.println(e);
              }
              out.close();
          }  
      }
  }
  </code></pre>