public Map<String, Integer> getGenreCounts() throws Exception {
		
		Connection connect = null;
		Statement statement = null;
		ResultSet resultSet = null;
		
		// Each element of the collection genreMap contains the name of a genre and its count
		Map<String, Integer> genreMap = new HashMap<String, Integer>();
		
		try {
			
			// First connect to the database
			connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/librarysystem?user=admin&password=123456");
			statement = connect.createStatement();
			
			createCheckOutView();
			
			resultSet = statement.executeQuery("SELECT HG.name, COUNT(*) "
					+ "FROM NoReturnCheckOut NRC, HasSearchGenre HG "
					+ "WHERE NRC.isbn = HG.isbn "
					+ "GROUP BY HG.name "
					+ "ORDER BY COUNT(*) desc");
			
			// Add genres and their counts into collection genreMap one at a time
			while(resultSet.next()){
				
				genreMap.put(resultSet.getString(1), resultSet.getInt(2));
				
			}
			
			statement.executeUpdate("DROP VIEW NoReturnCheckOut");
			
		} catch (Exception e) {
			System.out.println(e.getMessage());
			throw e;
		}
		
			finally
			{
				try {

					if(connect != null){
						connect.close();
					}
					
					if(statement != null){
						statement.close();
					}
					
					if(resultSet != null){
						resultSet.close();
					}
					
				} catch (Exception e) {	
					
				}
			}
		
		return genreMap;
	
	}