@Override
	public int doEndTag() throws JspException {
		if (query == null && bodyContent != null) {
			query = bodyContent.getString();
		}
		if (query == null || "".equals(query)) {
			throw new JspException(
			"Query must be provided, as an attribute or as BodyContent.");
		}

		final JspWriter out = pageContext.getOut();
		Connection conn = null;
		Statement statement = null;
		JspException exceptionToThrow = null;
		try {
			conn = getConnection();
			statement = conn.createStatement();
			resultSet = statement.executeQuery(query);
			SQLUtils.resultSetToHTML(resultSet, new PrintWriter(out),
				style1, style1, style2, pkey, link);

		} catch (SQLException e) {
			exceptionToThrow = new JspException("Database error", e);
		} finally {
			SQLUtils.cleanup(resultSet, statement, conn);
			if (exceptionToThrow != null) {
				throw exceptionToThrow;
			}
		}
		resetFields();
		return EVAL_PAGE;
	}