Class ResultSetMethodizer

  extended by com.evanmclean.evlib.velocity.AbstractResultSetMethodizer
      extended by com.evanmclean.evlib.velocity.ResultSetMethodizer
All Implemented Interfaces:

public class ResultSetMethodizer
extends AbstractResultSetMethodizer

A wrapper around a JDBC ResultSet that allows Velocity templates to access the columns in a template friendly way.

If you had a result set based on the following SQL statement:

 SELECT user_id, first_name, surname
 FROM users

And you add the result set to your context, wrapped in this methodizer, such as:

 context.put("query", new ResultSetMethodizer(result_set));

Then in your velocity template you could access it like this:

 #foreach( $row in $query )
   The ID for $row.FirstName $row.Surname is $row.UserId

Note that the result set must remain open while the template is merged. If you want a version that stores the results so you can close it immediately, use RowSetMethodizer.

See AbstractResultSetMethodizer.getPropertyNames(String) for details on how column names are mapped to property names by default.

Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Nested Class Summary
Nested classes/interfaces inherited from class com.evanmclean.evlib.velocity.AbstractResultSetMethodizer
Constructor Summary
ResultSetMethodizer(ResultSet rs)
Method Summary
 boolean hasNext()
 AbstractResultSetMethodizer.Row next()
Methods inherited from class com.evanmclean.evlib.velocity.AbstractResultSetMethodizer
getPropertyNames, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ResultSetMethodizer(ResultSet rs)
                    throws SQLException
Method Detail


public boolean hasNext()


public AbstractResultSetMethodizer.Row next()