private ArrayList<Module> populateModules() throws IllegalArgumentException {
		try{
        	openDatabase();
		}catch(Exception e){}
		String query = "SELECT * FROM t8005t2 .modules";
		ArrayList<Module> modules = new ArrayList<Module>();
		try {
			stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(query);
			while (rs.next()) {
				String id = rs.getString("name");
				ArrayList<String> clashedModules = getclashedModules(id);
				HashMap<String,Integer> coupledModules = getcoupledModules(id); 
				int examLength = rs.getInt("examLength");
				int moduleSize = numberOfStudents(id);
				String type = rs.getString("type");
				try{
					Module module = new Module(id, clashedModules, coupledModules, examLength, moduleSize, type);
					modules.add(module);
				}catch(IllegalArgumentException e){
					invalidModules=true;
					throw new IllegalArgumentException(e.getMessage());
				}
				
			}
		} catch (Exception e) {
			System.out.print(e);
			System.err.println("Problem executing populateModules query");
			System.err.println(e.getMessage());
		}
		
		try{
        	closeDatabase();
		}catch(Exception e){}
		return modules;
	}