public static Pagelist<Board> getBoard(int page, int numItemsInPage,
			String btype) throws SQLException, NamingException {
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;

		if (page <= 0) {
			page = 1;
		}

		DataSource ds = getDataSource();
		Pagelist<Board> result = new Pagelist<Board>(numItemsInPage, page);

		int startPos = (page - 1) * numItemsInPage;

		try {
			conn = ds.getConnection();
			stmt = conn
					.prepareStatement("SELECT COUNT(*) FROM board WHERE bdtype = ?");
			stmt.setString(1, btype);
			rs = stmt.executeQuery();
			rs.next();

			result.setNumItems(rs.getInt(1));

			rs.close();
			rs = null;
			stmt.close();
			stmt = null;

			stmt = conn
					.prepareStatement("SELECT * FROM board WHERE bdtype = ? ORDER BY bdnumber DESC LIMIT "
							+ startPos + ", " + numItemsInPage);
			stmt.setString(1, btype);
			rs = stmt.executeQuery();

			while (rs.next()) {
				result.getList().add(
						new Board(rs.getInt("bdnumber"), rs.getString("id"), rs
								.getString("title"), rs.getString("bdcomment"),
								rs.getTimestamp("bd_date"), rs.getInt("hits"),
								rs.getString("parent_id"), rs
										.getString("bdtype")));
			}
		} finally {
			if (rs != null)
				try {
					rs.close();
				} catch (SQLException e) {
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (SQLException e) {
				}
			if (conn != null)
				try {
					conn.close();
				} catch (SQLException e) {
				}
		}
		return result;
	}