public ResultPage<Book> getPatronRecord(int cardNumber, String search,
			String searchColumn, String orderColumn, int offset)
					throws SQLException {
		openPatronsDatabase();
		
		PreparedStatement statement = patronsConnection.prepareStatement(
				"SELECT * FROM CheckedOut WHERE CardNumber = ?");
		statement.setInt(1, cardNumber);
		
		ResultSet resultSet = statement.executeQuery();
		
		StringBuilder subQuery = new StringBuilder();
		
		subQuery.append("SELECT * FROM Titles WHERE ");
		if (resultSet.next()) {
			subQuery.append('(');
			subQuery.append("BookID = ").append(resultSet.getInt(1));
		} else {
			resultSet.close();
			statement.close();
			closePatronsDatabase();
			return new ResultPage<Book>(new ArrayList<Book>(), 0, true, true);
		}
		while (resultSet.next()) {
			subQuery.append(" OR ");
			subQuery.append("BookID = ").append(resultSet.getInt(1));
			if (resultSet.isLast()) {
				subQuery.append(") AND ");
			}
		}
		
		resultSet.close();
		statement.close();
		closePatronsDatabase();
		
		if (searchColumn.equals("Title")) {
			subQuery.append("Title");
		} else {
			subQuery.append("Author");
		}
		subQuery.append(" LIKE ? ORDER BY ");
		if (orderColumn.equals("Title")) {
			subQuery.append("Title, Author");
		} else {
			subQuery.append("Author, Title");
		}
		subQuery.append(" LIMIT 11 OFFSET ?");
		
		openBooksDatabase();
		
		PreparedStatement subStatement =
				booksConnection.prepareStatement(subQuery.toString());
		subStatement.setString(1, '%' + search + '%');
		subStatement.setInt(2, offset * 10);
		
		ResultSet subResultSet = subStatement.executeQuery();
		
		ArrayList<Book> results = new ArrayList<Book>(10);
		
		for (int book = 0; book < 10 && subResultSet.next(); book++) {
			results.add(new Book(subResultSet.getInt(1),
					subResultSet.getString(2), subResultSet.getString(3),
					true));
		}
		
		boolean isBeginning = false;
		boolean isEnd = false;
		
		if (offset == 0) {
			isBeginning = true;
		}
		if (!subResultSet.next()) {
			isEnd = true;
		}				
		
		subResultSet.close();
		subStatement.close();
		closeBooksDatabase();
		
		return new ResultPage<Book>(results, offset, isBeginning, isEnd);
	}