title: getting ORA-01722: invalid number error while inserting form data from webpage
body: <p>Im getting ORA-01722 error while inserting data from jsp form into the oracle database. i know that this error is pointing out to me that i am trying to insert a character string inside a number datatype but the problem is that everything looks to be fine to me but still im getting the error </p>
  
  <p>here is the code i use.</p>
  
  <p>roomregister.jsp</p>
  
  <pre><code>&lt;%
  String roomcategory=request.getParameter("category");
  if(roomcategory==null)
  {
      response.sendRedirect("categoryrooms.jsp");
      return;
  }
  //out.println(roomcategory);
  %&gt;
  &lt;script type="text/javascript" src="js/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(
          function ()
  {
      //getRoomsByCategory();
  }
          );
      var roomcategory="&lt;%=roomcategory%&gt;";
  
     /* function f1()
      //{
        //  var nrooms=$("#hdmaxrooms").val()-1;
          //alert(nrooms);
      }*/
      function chooseRoom(roomno)
      {
          $("#txtroomno").val(roomno);
      }
  
      function roombook()
      {
          var gender="";
          if(document.getElementById("txtmale").checked)
              gender="Male";
            if(document.getElementById("txtfemale").checked)
              gender="Female";
          if(gender=="")
              {
                  alert("Please select a gender");
                  return ;
              }
          var receiptno=$("#txtreceiptno").val();
          var name=$("#txtname").val();
          var address=$("#txtaddress").val(); 
          var idproof=$("#txtidproof").val();
          var dob=$("#txtdob").val();
          var contact=$("#txtcontact").val();
          var roomno=$("#txtroomno").val();
          var fromdate=$("#txtfromdate").val();
          var todate=$("#txttodate").val();
          var roomcategory=$("#txtroomcategory").val();
          var noofguestname=$("#txtnoofguestname").val();
          var charge=$("#txtcharge").val();
          var purpose=$("#txtpurpose").val();
  
          var bookingamount=$("#txtbookingamount").val();
  
  
          var url="bookrooms.jsp?receiptno="+ receiptno + "&amp;name=" + name + "&amp;address=" + address + "&amp;idproof=" + idproof + "&amp;dob=" + dob + "&amp;gender="+ gender + "&amp;contact=" + contact + "&amp;roomno="
          + roomno + "&amp;fromdate=" + fromdate +"&amp;todate="+ todate +  "&amp;roomcategory=" + roomcategory + "&amp;noofguestname=" + noofguestname +
          "&amp;charge=" + charge + "&amp;purpose=" + purpose + "&amp;bookingamount=" + bookingamount;
  
            var xhr=new XMLHttpRequest();
                  xhr.open("GET",url,true);
                  xhr.onreadystatechange=function (){roomBookResponse(xhr);};
                  xhr.send();
                  //alert(url);
  
      }
  
        function roomBookResponse(xhr)
           {
               if(xhr.readyState!=4)
                   return ;
               //getRoomsByCategory();
               $("#diverrors").html(xhr.responseText);
              // alert("xZXZX" + xhr.responseText);
           }
  
           function getroom()
           {
              var fromdate =$("#txtfromdate").val();
              var todate =$("#txttodate").val();
  
  
              var url="roomsforbooking.jsp?fromdate="+ fromdate + "&amp;todate=" + todate + "&amp;category=" + roomcategory ;
                  //alert(url);
  
            var xhr=new XMLHttpRequest();
                  xhr.open("GET",url,true);
                  xhr.onreadystatechange=function (){getRoomResponse(xhr);};
                  xhr.send();
                  //alert(url);
  
           }
            function getRoomResponse(xhr)
           {
               if(xhr.readyState!=4)
                   return ;
              // getRoomsByCategory();
               $("#diverrors").html(xhr.responseText);
              // alert("xZXZX" + xhr.responseText);
           }
  &lt;/script&gt;
  
  &lt;font color="white"&gt;
  
  &lt;div id="divroomsbycategory"&gt;&lt;/div&gt;
  
  
  
  
  &lt;div id="image" class="image"&gt;
  
  &lt;center&gt;
      &lt;table  class="divcenter" width="60%" border="0"&gt;
          &lt;tr&gt;&lt;td colspan="2" align="center"&gt;ROOM BOOKING&lt;/td&gt;&lt;/tr&gt;
  
           &lt;tr&gt;&lt;td colspan="2" align="center"&gt; &lt;div id="diverrors"&gt;&lt;/div&gt; &lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;&lt;BR&gt;Receipt_No&lt;/td&gt;&lt;td&gt;&lt;BR&gt;&lt;input type="text" id="txtreceiptno"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtname"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Address&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtaddress"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Id_Proof&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtidproof"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Date_of_Birth&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtdob"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
           &lt;tr&gt;&lt;td&gt;Gender&lt;/td&gt;&lt;td&gt;Male&lt;input type="radio" id="txtmale" value="male" name="gender"/&gt;
           Female&lt;input type="radio" id="txtfemale" value="female" name="gender"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
           &lt;tr&gt;&lt;td&gt;Contact&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtcontact"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt; Room_No&lt;/td&gt;&lt;td&gt;
                   &lt;input type="text" id="txtroomno" readonly="readonly"/&gt;
                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp&amp;nbsp;&amp;nbsp;&amp;nbsp;
                   &lt;input type="button" value="GET" onclick="getroom();" class="divbutton"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
           &lt;tr&gt;&lt;td&gt;From_Date&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtfromdate"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;TO-date&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txttodate"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Room_Category&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtroomcategory"  readonly="readonly"  value="&lt;%=roomcategory%&gt;"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;No_Of_Guest&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtnoofguestname"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Charge&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtcharge"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;Purpose&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtpurpose"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  
           &lt;tr&gt;&lt;td&gt;Booking-Amount&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="txtbookingamount"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  
           &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;BR&gt;&lt;input type="button" value="SUBMIT" onclick="roombook();" class="divbutton"/&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;div id="divroomsbycategory"&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  &lt;/center&gt;
  
  &lt;/div&gt;  
           &lt;/font&gt;    
           &lt;style&gt;
              .divbutton:hover
              {
                  border: solid white;
                 background-color:  seagreen;
              }
              .divcenter:hover
  
  
              {
                   border: solid;
                  border-top-color:  white;
                  border-bottom-color:  white;
                  border-left-color: white;
                  border-right-color: white;
  
  
              }
              .image
              {
                  width: 100%;
                  height: 600px;
                  background-image: url("images/332.jpg");
              }
          &lt;/style&gt;
  </code></pre>
  
  <p>bookrooms.jsp</p>
  
  <pre><code>&lt;%@page import="utilitiespackage.Date"%&gt;
  &lt;%@page import="java.sql.Connection"%&gt;
  &lt;%@page import="dbpackage.DBConnector"%&gt;
  &lt;%@page import="java.sql.PreparedStatement"%&gt;
  &lt;%@page import="validationspackage.Validations"%&gt;
  
    &lt;%
      try
      {
  String receiptno=request.getParameter("receiptno");
  String name=request.getParameter("name");
  String address=request.getParameter("address");
  String idproof=request.getParameter("idproof");
  String dob=request.getParameter("dob");
  String gender=request.getParameter("gender");
  String contact=request.getParameter("contact");
  String roomno=request.getParameter("roomno");
  String fromdate=request.getParameter("fromdate");
  String todate=request.getParameter("todate");
  String roomcategory=request.getParameter("roomcategory");
  String noofguestname=request.getParameter("noofguestname");
  String charge=request.getParameter("charge");
  String purpose=request.getParameter("purpose");
  
  String bookingamount=request.getParameter("bookingamount");
  
   //Connection con=DBConnector.getConnection(session);
  
  PreparedStatement ps=DBConnector.getPreparedStatement(session, "insert into roomregister values ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
  ps.setString(1,receiptno);
  ps.setString(2,name);
  ps.setString(3,address);
  ps.setString(4,idproof);
  ps.setString(5,contact);
  ps.setString(6,roomno);
  ps.setString(7,fromdate);
  ps.setString(8,roomcategory);
  ps.setString(9,noofguestname);
  ps.setString(10,charge);
  ps.setString(11,purpose);
  ps.setString(12,gender);
  ps.setString(13,dob);
  ps.setString(14,bookingamount);
  
  Date d1=new Date(fromdate);
  Date d2=new Date(todate);
  for(;Date.compare(d1, d2)&lt;0;d1.advance())
  {
      ps.setString(6, "" + d1);
      ps.executeUpdate();
  }
  
  
  
  
  out.println(Validations.setSuccess("Booked"));
  
  //String message=Validations.setSuccess("deleted");
  //out.println(message);
      }
      catch(Exception ex)
      {
          System.out.println(ex);
          out.println(Validations.setError(ex));
  
      }
  %&gt;
  </code></pre>
  
  <p>my database table:</p>
  
  <p><a href="https://i.stack.imgur.com/JRow8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JRow8.png" alt="enter image description here"></a></p>
  
  <p>error that i am getting:
  <a href="https://i.stack.imgur.com/cOOVE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cOOVE.png" alt="enter image description here"></a></p>