Guest User

Untitled

a guest
Dec 30th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. JComboBox comboTeam;
  2. JComboBox comboPlayer;
  3. JButton button;
  4. Connection con = null;
  5. Statement st = null;
  6. ResultSet rs = null;
  7. /* String[] playerString = {"TeamCaptain", "Striker1", "Striker2", "Striker3", "Striker4", "Midfielder1", "Midfielder2", "Midfielder3", "Defence1", "Defence2", "Defence3", "Goalkeeper", "Manager", "Coach"};
  8. */
  9. comboTeam = new JComboBox();
  10. c.fill = GridBagConstraints.HORIZONTAL;
  11. c.gridx = 0;
  12. c.gridy = 1;
  13. paneDelp.add(comboTeam, c);
  14. String APlayer = (String) comboTeam.getSelectedItem();
  15.  
  16. comboPlayer = new JComboBox(/*playerString*/);
  17. c.fill = GridBagConstraints.HORIZONTAL;
  18. c.gridx = 0;
  19. c.gridy = 2;
  20. paneDelp.add(comboPlayer, c);
  21.  
  22. try {
  23. con = DriverManager.getConnection("jdbc:derby://localhost:1527/" + "jfl", "jfl", "jfl");
  24. st = con.createStatement();
  25. String s = "SELECT Teamname from JFL.TEAMS";
  26. rs = st.executeQuery(s);
  27. while (rs.next()) {
  28. comboTeam.addItem(rs.getString(1));
  29. }
  30. } catch (Exception f) {
  31. JOptionPane.showMessageDialog(null, "ERROR");
  32. } finally {
  33. try {
  34. st.close();
  35. rs.close();
  36. con.close();
  37. } catch (Exception f) {
  38. JOptionPane.showMessageDialog(null, "ERROR CLOSE");
  39. }
  40. }
  41.  
  42. try {
  43. con = DriverManager.getConnection("jdbc:derby://localhost:1527/" + "jfl", "jfl", "jfl");
  44. st = con.createStatement();
  45. String s = "SELECT MANAGER FROM JFL.TEAMS WHERE Teamname=" + APlayer;
  46. rs = st.executeQuery(s);
  47. while (rs.next()) {
  48. comboPlayer.addItem(rs.getString(1));
  49. }
  50. } catch (Exception f) {
  51. JOptionPane.showMessageDialog(null, "EROR");
  52. } finally {
  53. try {
  54. st.close();
  55. rs.close();
  56. con.close();
  57. } catch (Exception f) {
  58. JOptionPane.showMessageDialog(null, "ERROR CLOSE");
  59. }
  60. }
Add Comment
Please, Sign In to add comment