title: java.lang.NumberFormatException: For input string: "" while saving to database
body: <p>I want to add new room, I would type the room details, <code>Room Number, Room type, Bed number and Rates</code> into the text fields, when I click save, I get the error <code>java.lang.NumberFormatException: For input string: ""</code></p>
  
  <p>The error originates from <code>at RoomMang.jButton1ActionPerformed(RoomMang.java:352)</code> which is <code>fetchFromTextF();</code> function. See Image : <img src="https://i.stack.imgur.com/HCIY8.png" alt="RoomMgt"> </p>
  
  <p>My insert statement using <code>System.out.println (insertquery);</code> looks like this:
  <code>insert into roomdetail(room_no,room_type,room_rate,room_bed)values('','','','');</code></p>
  
  <p>This is how i fetch the data from the textfields:</p>
  
  <pre><code>public void fetchFromTextF(){
      rno=rnumber.getText();
      rtype=jTextField2.getText();
      rrate=Integer.parseInt(jTextField3.getText());
      rbed=jTextField4.getText();
  }
  </code></pre>
  
  <p>And this is my save action performed button:</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      try {
          clearTextF();
          enableTextF();
          String query = "SELECT * FROM roomdetail where room_no like '" +           rnumber.getText() + "';";
          smt = con.createStatement();
          rs1 = smt.executeQuery(query);
          if (!rs1.next()) {
              try {
                  if (evt.getActionCommand().equals("Save")) {
                      fetchFromTextF();
                      int code = JOptionPane.showConfirmDialog(this, "Information of Room No." +rno+ " will be added in database.", "Confirmation", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
                      if (code == JOptionPane.YES_OPTION) {
                          String insertquery = "insert into roomdetail(room_no,room_type,room_rate,room_bed)values('" +rno + "','" + rtype + "'," + rrate + ",'" + rbed + "');";
                          smt = con.createStatement();
                          int success = smt.executeUpdate(insertquery);
                          if (success &gt; 0) {
                              JOptionPane.showMessageDialog(this, "Record Saved");
                              jButton1.setText("New");
                          } else {
                              JOptionPane.showMessageDialog(this, "Problem in Saving. Retry");
                          }
                      } else {
                      }
                  } else if (evt.getActionCommand().equals("New")) {
                      clearTextF();
                      jButton1.setText("Save");
                  }
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
          } else {
              JOptionPane.showMessageDialog(this, "Room No. already used, Give another Room No.");
          }
      } catch (Exception ex) {
      }
  }             
  </code></pre>