|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.commons.scaffold.sql.ResultSetUtils
General purpose utility methods related to ResultSets
| Constructor Summary | |
ResultSetUtils()
|
|
| Method Summary | |
static java.util.Collection |
getCollection(java.lang.Object target,
java.sql.ResultSet resultSet)
Return a ArrayList of beans populated from a ResultSet. |
static boolean |
getElement(java.lang.Object target,
java.sql.ResultSet resultSet)
Populate target bean with the first record from a ResultSet. |
static java.util.Map |
getMap(java.sql.ResultSet resultSet)
Returns next record of result set as a Map. |
static java.util.Collection |
getMaps(java.sql.ResultSet resultSet)
Return a Collection of Maps, each representing a row from the ResultSet. |
static void |
putEntry(java.util.Map properties,
java.sql.ResultSetMetaData metaData,
java.sql.ResultSet resultSet,
int i)
Map JDBC objects to Java equivalents. |
static void |
setProperties(java.lang.Object bean,
java.util.Map properties)
Deprecated. Use BeanUtils.CopyProperties instead. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ResultSetUtils()
| Method Detail |
public static java.util.Map getMap(java.sql.ResultSet resultSet)
throws java.sql.SQLException
resultSet - The ResultSet to process.
java.sql.SQLException - if an error occurs.
public static java.util.Collection getMaps(java.sql.ResultSet resultSet)
throws java.sql.SQLException
resultSet - The ResultSet to process.
java.sql.SQLException - if an error occurs.
public static void setProperties(java.lang.Object bean,
java.util.Map properties)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
The particular setter method to be called for each property is determined using the usual JavaBeans introspection mechanisms. Thus, you may identify custom setter methods using a BeanInfo class that is associated with the class of the bean itself. If no such BeanInfo class is available, the standard method name conversion ("set" plus the capitalized name of the property in question) is used.
NOTE: It is contrary to the JavaBeans Specification to have more than one setter method (with different argument signatures) for the same property.
This method adopted from the Apache Commons BeanUtils.populate.
bean - JavaBean whose properties are being populatedproperties - Map keyed by property name, with the
corresponding value to be set
java.lang.IllegalAccessException - if the caller does not have
access to the property accessor method
java.lang.reflect.InvocationTargetException - if the property accessor method
throws an exception
public static void putEntry(java.util.Map properties,
java.sql.ResultSetMetaData metaData,
java.sql.ResultSet resultSet,
int i)
throws java.sql.SQLException
Some types not supported. Many not work with all drivers.
Makes binary conversions of BIGINT, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT, TIME, TIMESTAMP, TINYINT. Makes Sting conversions of CHAR, CLOB, VARCHAR, LONGVARCHAR, BLOB, LONGVARBINARY, VARBINARY.
DECIMAL, INTEGER, SMALLINT, TIMESTAMP, CHAR, VARCHAR tested with MySQL and Poolman. Others not guaranteed.
java.sql.SQLException
public static boolean getElement(java.lang.Object target,
java.sql.ResultSet resultSet)
throws java.sql.SQLException
resultSet - The ResultSet whose parameters are to be used
to populate bean propertiestarget - An instance of the bean to populate
java.sql.SQLException - if an exception is thrown while setting
property values, populating the bean, or accessing the ResultSet
public static java.util.Collection getCollection(java.lang.Object target,
java.sql.ResultSet resultSet)
throws java.sql.SQLException
resultSet - The ResultSet whose parameters are to be used
to populate bean propertiestarget - An instance of the bean to populate
java.sql.SQLException - if an exception is thrown while setting
property values, populating the bean, or accessing the ResultSet
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||