Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT MatchTeam.FootballMatchID, MatchTeam.TeamID, MatchTeam.GameType, MatchProtocol.MatchTeamID, MatchProtocol.GoalNumber, MatchProtocol.YellowCardNumber, MatchProtocol.RedCardNumber
- FROM MatchTeam LEFT JOIN MatchProtocol ON MatchTeam.ID = MatchProtocol.MatchTeamID
- WHERE (((MatchTeam.GameType)="Away"));
- SELECT MatchTeam.FootballMatchID, MatchTeam.TeamID, MatchTeam.GameType, MatchProtocol.MatchTeamID, MatchProtocol.GoalNumber, MatchProtocol.YellowCardNumber, MatchProtocol.RedCardNumber
- FROM MatchTeam LEFT JOIN MatchProtocol ON MatchTeam.ID = MatchProtocol.MatchTeamID
- WHERE (((MatchTeam.GameType)="Home"));
- SELECT qryHomeMatches.FootballMatchID, qryHomeMatches.TeamID AS HomeTeamID, qryAwayMatches.TeamID AS AwayTeamID, qryHomeMatches.GoalNumber AS HomeTeamGoals, qryAwayMatches.GoalNumber AS AwayTeamGoals, [HomeTeamGoals]>[AwayTeamGoals] AS HomeTeamWin, [HomeTeamGoals]=[AwayTeamGoals] AS NoWin, [HomeTeamGoals]<[AwayTeamGoals] AS AwayTeamWin
- FROM qryHomeMatches INNER JOIN qryAwayMatches ON qryHomeMatches.FootballMatchID = qryAwayMatches.FootballMatchID;
- btnqryAwayMatches.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Connection con = null;
- Statement st = null;
- ResultSet rs = null;
- String s;
- JFrame frame;
- String url = "jdbc:hsqldb:file:db_data/myFootballDB;ifexists=true;shutdown=true";
- String username = "SA";
- String password = "";
- try {
- con = DriverManager.getConnection(url, username, password);
- st = con.createStatement();
- s = "SELECT MATCHTEAM.FOOTBALLMATCHID, MATCHTEAM.TEAMID, MATCHTEAM.GAMETYPE, "
- + "MATCHPROTOCOL.MATCHTEAMID, MATCHPROTOCOL.GOALNUMBER, "
- + "MATCHPROTOCOL.YELLOWCARDNUMBER, "
- + "MATCHPROTOCOL.REDCARDNUMBER "
- + "FROM MATCHTEAM LEFT JOIN MATCHPROTOCOL ON MATCHTEAM.ID = MATCHPROTOCOL.MATCHTEAMID "
- + "WHERE (((MATCHTEAM.GAMETYPE)='Away'));";
- rs = st.executeQuery(s);
- ResultSetMetaData rsmt = rs.getMetaData();
- int c = rsmt.getColumnCount();
- Vector<String> column = new Vector<String>(c);
- for (int i = 1; i <= c; i++) {
- column.add(rsmt.getColumnName(i));
- }
- Vector<Vector<String>> data = new Vector<Vector<String>>();
- Vector<String> row = new Vector<String>();
- while (rs.next()) {
- row = new Vector<String>(c);
- for(int i = 1; i <= c; i++) {
- row.add(rs.getString(i));
- }
- data.add(row);
- }
- frame = new JFrame();
- frame.setTitle("Away Match Results");
- frame.setSize(700,420);
- frame.setLocationByPlatform(true);
- frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- JPanel panel = new JPanel();
- JTable table = new JTable(data, column);
- JScrollPane jsp = new JScrollPane(table);
- panel.setLayout(new BorderLayout());
- panel.add(jsp, BorderLayout.CENTER);
- frame.setContentPane(panel);
- frame.setVisible(true);
- } catch(Exception exc) {
- exc.printStackTrace();
- JOptionPane.showMessageDialog(null, "Error");
- } finally {
- try {
- st.close();
- rs.close();
- con.close();
- } catch(Exception exception) {
- JOptionPane.showMessageDialog(null, "Error close");
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement