cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sonney <ke...@webslingerz.com>
Subject RE: new sql logicsheet!
Date Tue, 05 Sep 2000 13:59:36 GMT
On Tue, 5 Sep 2000, John Morrison wrote:
> I know the example is a little contrived, what I'm essentially attempting to
> do is get a result from a result set twice.  JDBC doesn't like this.  What I'd
> like to know is if there's a way to get around this limitation in your taglib?

If you mean "get two results from the same resultset", I would think the
answer is going to be no. JDBC *DOES* support this :

ResultSet rs = stmt.executeQuery(queryString);
while (rs.next()) {
	System.out.println(rs.getString("ID"));
	System.err.println(rs.getString("ID"));
}

Which you can easily do in esql like so :

<esql:results>
	<result_1><esql:get-string column="ID"/></result_1>
	<result_1a><esql:get-string column="ID"/></result_1a>
</esql:results>

This gets the same *RESULT* twice. However, if you want to get two
results from the same ResultSet in JDBC, it's better to steam it all into
a Hashtable or Vector (or List, or whatever) than post-process it :

Vector resultList = new Vector();
int resultNumber = 0;
while (rs.next()) {
	resultList.add(rs.getString("ID"));
	resultNumber++;
}
for (i=0; i < resultNumber+1; i++) {
	System.out.println("Current result is "+resultList.get(i));
	if (i > 0) {
		System.out.println("Previous Value is "+resultList.get(i-1));
	} 
	System.out.println("--");
}

Now all of this would have to be done via some really ugly XSP code,
which I'm not coherent enough yet to create (dangit, where's that
coffee??? *grin*)

-- 
+-------------------------------------------+
| Kevin Sonney        kevin@webslingerZ.com |
| Systems Programmer    www.webslingerZ.com |
+-------------------------------------------+



Mime
View raw message