morgand 01/01/30 16:56:52
Modified: jdbc/src/org/apache/taglibs/jdbc/resultset
BaseGetterTag.java
Log:
added code for using the ResultSetMetaData in getColumn
Revision Changes Path
1.2 +41 -2
jakarta-taglibs/jdbc/src/org/apache/taglibs/jdbc/resultset/BaseGetterTag.java
Index: BaseGetterTag.java
===================================================================
RCS file:
/home/cvs/jakarta-taglibs/jdbc/src/org/apache/taglibs/jdbc/resultset/BaseGetterTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseGetterTag.java 2001/01/08 21:17:17 1.1
+++ BaseGetterTag.java 2001/01/31 00:56:51 1.2
@@ -59,6 +59,8 @@
package org.apache.taglibs.jdbc.resultset;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
@@ -73,6 +75,8 @@
protected int _position = 1;
protected String _attributeName = null;
protected String _scope = "page";
+ protected ResultSetTag _tag = null;
+ protected ResultSetMetaData _metaData = null;
/**
* Sets the column number of the result set.
@@ -127,18 +131,53 @@
* @return ResultSet of the resultset tag
*/
protected ResultSet getResultSet() throws JspTagException {
+ if (_tag == null) {
+ _tag = getResultSetTag();
+ }
+ return _tag.getResultSet();
+ }
+
+ /**
+ * Get the MetaData object for this result set
+ *
+ * @return Meta data object
+ * @exception JspTagException
+ */
+ protected ResultSetMetaData getMetaData() throws JspTagException {
+ if (_tag == null) {
+ _tag = getResultSetTag();
+ }
+ if (_metaData == null) {
+ try {
+ _metaData = _tag.getResultSet().getMetaData();
+ } catch (SQLException e) {
+ throw new JspTagException(e.toString());
+ }
+ }
+ return _metaData;
+ }
+
+ /**
+ * Get the parent result set tag
+ *
+ * @return ResultSetTag
+ * @exception JspTagException
+ */
+ protected ResultSetTag getResultSetTag() throws JspTagException{
try {
ResultSetTag rsetTag =
(ResultSetTag) findAncestorWithClass(this,
Class.forName("org.apache.taglibs.jdbc.resultset.ResultSetTag"));
- return rsetTag.getResultSet();
+ return rsetTag;
} catch (ClassNotFoundException e) {
throw new JspTagException(e.toString());
}
}
-
+
public void release() {
_position = 1;
_attributeName = null;
_scope = "page";
+ _tag = null;
+ _metaData = null;
}
}