public void GetDishID() { String recipe = txt_Recipe.getText(); String commandText = "SELECT ID from dish WHERE Recipe = " + "'" + recipe + "'"; ResultSet rs = SQL.ExecuteResultSet(commandText); try { while ((rs != null) && (rs.next())) { dishID = rs.getInt("ID"); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e.toString()); } }