public List<Product> viewAllProducts(int group, int offset, int recordsOnPage, 
    		Sorting sorting, SortingType sortingType) {
    	StringBuilder queryBuilder = new StringBuilder();
    	queryBuilder.append("SELECT SQL_CALC_FOUND_ROWS * FROM product ");
    	if (group > 0) {
    		queryBuilder.append("where group_id=").append(group);
    	}
    	if (!Sorting.DEFAULT.equals(sorting)) {
    		queryBuilder.append(" ORDER BY ").append("product_").
    			append(sortingType.getValue()).append(" ").append(sorting.getType());
    	} 
    	queryBuilder.append(" limit ").append(offset).append(", ").append(recordsOnPage);
    	
		List<Product> list = new ArrayList<Product>();
		Product product = null;
		try {
			connection = ConnectionFactory.getInstance().getConnection();
			statement = connection.createStatement();

			ResultSet rs = statement.executeQuery(queryBuilder.toString());
			while (rs.next()) {
				product = new Product();
				product.setProductName(rs.getString("product_name"));
				product.setProductPrice(rs.getInt("product_price"));

				list.add(product);
			}
			rs.close();

			rs = statement.executeQuery("SELECT FOUND_ROWS()");
			if (rs.next()) {
				this.productCount = rs.getInt(1);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} finally {
			try {
				if (statement != null)
					statement.close();
				if (connection != null)
					connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return list;
	}