hi I've been working this for 2 days and even google it but I can't figured the right answer.
I can check STRING if it is empty.
here is my code
private void saveButton3ActionPerformed(java.awt.event.ActionEvent evt) { String inventcodef = inventCodeField.getText(); String inventnamef = inventNameField.getText(); String categ = cmbname.getSelectedItem().toString(); double inventreorderf = Double.parseDouble(inventReorderField.getText()); String inventlocf = inventLocationField.getText(); String inventstat = inventStatusArea.getText(); if ((inventcodef.trim().length()==0) || (inventnamef.trim().length()== 0)||(inventreorderf == 0)) { JOptionPane.showMessageDialog(null,"Item Code / Item Name / ReOrderpoint is empty!"); } else try { String SQL2 = "INSERT INTO inventory VALUES (" + "'" + inventcodef + "'" + "," + "'" + inventnamef + "'" + "," + "'" + categ + "'" + "," + "'" + inventreorderf + "'" + "," + "'" + inventlocf + "'" + "," + "'" + inventstat + "'" + ")"; PreparedStatement stamt = connect.prepareStatement(SQL2); stamt.executeUpdate(); Double.parseDouble(inventReorderField.getText()); JOptionPane.showMessageDialog(null,"Item Code: " + inventcodef + " Successfully saved!"); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null,e.getMessage()); inventReorderField.selectAll(); inventReorderField.requestFocus(); return; } catch (Exception f) { JOptionPane.showMessageDialog(null,(f.getMessage())); } }
Thank you!