public ResultPage<Book> getBooks(String search, String searchColumn,
			String orderColumn, int offset) throws SQLException {
		openBooksDatabase();
	
		StringBuilder query =
				new StringBuilder("SELECT * FROM Titles WHERE ");
		if (searchColumn.equals("Title")) {
			query.append("Title");
		} else {
			query.append("Author");
		}
		query.append(" LIKE ? ORDER BY ");
		if (orderColumn.equals("Title")) {
			query.append("Title, Author");
		} else {
			query.append("Author, Title");
		}
		query.append(" LIMIT 11 OFFSET ?");
		
		PreparedStatement statement =
				booksConnection.prepareStatement(query.toString());

		statement.setString(1, '%' + search + '%');
		statement.setInt(2, offset * 10);
		
		ResultSet resultSet = statement.executeQuery();
		
		ArrayList<Book> results = new ArrayList<Book>(10);
		
		openPatronsDatabase();
		
		for (int book = 0; book < 10 && resultSet.next(); book++) {
			PreparedStatement subStatement =
					patronsConnection.prepareStatement(
							"SELECT * FROM CheckedOut " +
							"WHERE BookNumber = ?");
			subStatement.setInt(1, resultSet.getInt(1));
			ResultSet subResultSet = subStatement.executeQuery();
			
			results.add(new Book(resultSet.getInt(1),
					resultSet.getString(2),	resultSet.getString(3),
					subResultSet.next()));
			
			subResultSet.close();
			subStatement.close();
		}
		
		closePatronsDatabase();
		
		boolean isBeginning = false;
		boolean isEnd = false;
		
		if (offset == 0) {
			isBeginning = true;
		}
		if (!resultSet.next()) {
			isEnd = true;
		}
		
		resultSet.close();
		statement.close();
		closeBooksDatabase();
		
		return new ResultPage<Book>(results, offset, isBeginning, isEnd);
	}