// Add fee method private void addFees() { try { float feesadded = Float.parseFloat(addfeestextfield.getText()); int id = table.getSelectionModel().getMinSelectionIndex(); long studentid = (long) table.getValueAt(id, 0); int index = feestable.getSelectionModel().getMinSelectionIndex(); String coursename = (String) feestable.getValueAt(index, 0); Database db = new Database(); db.addFees(feesadded, studentid, coursename); updateFeesData(studentid); addfeestextfield.setText(""); } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } }