@SuppressWarnings("unchecked")
    public String getTeamMatchTable() {
        PreparedStatement st = null;
        ResultSet rs = null;
        JSONArray json = new JSONArray();
        try {
            conn = dbconn.getConnection();
            st = conn.prepareStatement("SELECT m.id, m.event_id, e.name, m.match_number, (m.auton_top)*6 + (m.auton_middle)*4  + (m.auton_bottom)*2 as auton, (m.teleop_top)*3 + (m.teleop_middle)*2 + (m.teleop_bottom) + (m.teleop_pyramid)*5 as teleop, (m.pyramid_level)*10 as climb, (m.auton_top)*6 + (m.auton_middle)*4  + (m.auton_bottom)*2 + (m.teleop_top)*3 + (m.teleop_middle)*2 + (m.teleop_bottom) + (m.teleop_pyramid)*5 + (m.pyramid_level)*10 as total FROM match_record_2013 m, events e WHERE team_id = ? AND m.event_id = e.id");
            st.setInt(1, getSelectedTeam());
            rs = st.executeQuery();
            while (rs.next()) {
                JSONObject o = new JSONObject();
                o.put("id", rs.getInt("id"));
                o.put("event_id", rs.getInt("event_id"));
                o.put("event_name", rs.getString("name"));
                o.put("match_id", rs.getInt("match_number"));
                o.put("autonomous", rs.getInt("auton"));
                o.put("teleop", rs.getInt("teleop"));
                o.put("climb", rs.getInt("climb"));
                o.put("total_points", rs.getInt("total"));
                json.add(o);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try{
                conn.close();
                st.close();
                rs.close();
            }catch (SQLException e) {
                System.out.println("Error closing query");
            }
        }
        return json.toString();
    }