@SuppressWarnings("unchecked")
    private String generateColorTeamTable(String color) {
        PreparedStatement st = null;
        ResultSet rs = null;
        JSONArray json = new JSONArray();
        try {
            conn = dbconn.getConnection();
            st = conn.prepareStatement("SELECT id, team_id, auton_top*6 + auton_middle*4  + auton_bottom*2 as auton, teleop_top*3 + teleop_middle*2 + teleop_bottom + teleop_pyramid*5 as teleop, pyramid_level*10 as climb, auton_top*6 + auton_middle*4  + auton_bottom*2 + teleop_top*3 + teleop_middle*2 + teleop_bottom + teleop_pyramid*5 + pyramid_level*10 as total FROM match_record_2013 where event_id = ? AND match_number = ? AND color = ?");
            st.setInt(1, getSelectedEvent());
            st.setInt(2, getSelectedMatch());
            st.setString(3, color);
            rs = st.executeQuery();
            while (rs.next()) {
                JSONObject o = new JSONObject();
                o.put("id", rs.getInt("id"));
                o.put("team_id", rs.getInt("team_id"));
                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();
    }