|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.scaffold.sql.ResultSetUtils
public class ResultSetUtils
General purpose utility methods related to ResultSets
Constructor Summary | |
---|---|
ResultSetUtils()
|
Method Summary | |
---|---|
static Collection |
getCollection(Object target,
ResultSet resultSet)
Return a ArrayList of beans populated from a ResultSet. |
static boolean |
getElement(Object target,
ResultSet resultSet)
Populate target bean with the first record from a ResultSet. |
static Map |
getMap(ResultSet resultSet)
Returns next record of result set as a Map. |
static Collection |
getMaps(ResultSet resultSet)
Return a Collection of Maps, each representing a row from the ResultSet. |
static void |
putEntry(Map properties,
ResultSetMetaData metaData,
ResultSet resultSet,
int i)
Map JDBC objects to Java equivalents. |
static void |
setProperties(Object bean,
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 Map getMap(ResultSet resultSet) throws SQLException
resultSet
- The ResultSet to process.
SQLException
- if an error occurs.public static Collection getMaps(ResultSet resultSet) throws SQLException
resultSet
- The ResultSet to process.
SQLException
- if an error occurs.public static void setProperties(Object bean, Map properties) throws IllegalAccessException, 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
IllegalAccessException
- if the caller does not have
access to the property accessor method
InvocationTargetException
- if the property accessor method
throws an exceptionpublic static void putEntry(Map properties, ResultSetMetaData metaData, ResultSet resultSet, int i) throws 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.
SQLException
public static boolean getElement(Object target, ResultSet resultSet) throws SQLException
resultSet
- The ResultSet whose parameters are to be used
to populate bean propertiestarget
- An instance of the bean to populate
SQLException
- if an exception is thrown while setting
property values, populating the bean, or accessing the ResultSetpublic static Collection getCollection(Object target, ResultSet resultSet) throws SQLException
resultSet
- The ResultSet whose parameters are to be used
to populate bean propertiestarget
- An instance of the bean to populate
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 |