Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JComboBox comboTeam;
- JComboBox comboPlayer;
- JButton button;
- Connection con = null;
- Statement st = null;
- ResultSet rs = null;
- /* String[] playerString = {"TeamCaptain", "Striker1", "Striker2", "Striker3", "Striker4", "Midfielder1", "Midfielder2", "Midfielder3", "Defence1", "Defence2", "Defence3", "Goalkeeper", "Manager", "Coach"};
- */
- comboTeam = new JComboBox();
- c.fill = GridBagConstraints.HORIZONTAL;
- c.gridx = 0;
- c.gridy = 1;
- paneDelp.add(comboTeam, c);
- String APlayer = (String) comboTeam.getSelectedItem();
- comboPlayer = new JComboBox(/*playerString*/);
- c.fill = GridBagConstraints.HORIZONTAL;
- c.gridx = 0;
- c.gridy = 2;
- paneDelp.add(comboPlayer, c);
- try {
- con = DriverManager.getConnection("jdbc:derby://localhost:1527/" + "jfl", "jfl", "jfl");
- st = con.createStatement();
- String s = "SELECT Teamname from JFL.TEAMS";
- rs = st.executeQuery(s);
- while (rs.next()) {
- comboTeam.addItem(rs.getString(1));
- }
- } catch (Exception f) {
- JOptionPane.showMessageDialog(null, "ERROR");
- } finally {
- try {
- st.close();
- rs.close();
- con.close();
- } catch (Exception f) {
- JOptionPane.showMessageDialog(null, "ERROR CLOSE");
- }
- }
- try {
- con = DriverManager.getConnection("jdbc:derby://localhost:1527/" + "jfl", "jfl", "jfl");
- st = con.createStatement();
- String s = "SELECT MANAGER FROM JFL.TEAMS WHERE Teamname=" + APlayer;
- rs = st.executeQuery(s);
- while (rs.next()) {
- comboPlayer.addItem(rs.getString(1));
- }
- } catch (Exception f) {
- JOptionPane.showMessageDialog(null, "EROR");
- } finally {
- try {
- st.close();
- rs.close();
- con.close();
- } catch (Exception f) {
- JOptionPane.showMessageDialog(null, "ERROR CLOSE");
- }
- }
Add Comment
Please, Sign In to add comment