@Override
	public List<Category> getCategoriesFromProductId(int productId) throws StorageException {
		ResultSet rs = null;
	    Connection conn = null;
	    PreparedStatement pstmt = null;
	    categories.clear();
	    
	    try {
			conn = Database.getConnection();
			
			String query = "SELECT categories.id, categories.staff_id, categories.category_name "
						 + "FROM categories, products_categories, products "
						 + "WHERE categories.id = products_categories.categories_id "
						 + "AND products.id = products_categories.products_id "
						 + "AND products.id = ?;";
			
			pstmt = conn.prepareStatement(query);
			
			pstmt.setInt(1, productId);
			
			rs = pstmt.executeQuery();
			
			// Display all the data in the table.
			while (rs.next()) {
				Category tempCategory = new Category(rs.getInt("id"));
				tempCategory.setStaffId(rs.getInt("staff_id"));
				tempCategory.setCategoryName(rs.getString("category_name"));
				
				categories.add(tempCategory);
	        }
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new StorageException(e.getMessage());
		} catch (SQLException e) {
			e.printStackTrace();
			throw new StorageException(e.getMessage());
		} finally {
			try {
				if(rs != null) {
					rs.close();
				}
				if(pstmt != null) {
					pstmt.close();
				}
				if(conn != null) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
				throw new StorageException(e.getMessage());
			}
		}
	    
	    return categories;
	}