Java BeanUtils Tutorial
Standard JavaBeans
Dynamic Beans (DynaBeans)
Data Type Conversions
Utility Objects & Classes
Collections
Java BeanUtils Useful Resources
Selected Reading
Standard JavaBeans
- Suppressing Properties
- Customizing Introspection
- Nested Property Access
- Basic Property Access
- Background
Dynamic Beans (DynaBeans)
Data Type Conversions
Utility Objects & Classes
Collections
Java BeanUtils Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ResultSetDynaClass
Java BeanUtils - ResultSetDynaClass
Description
The ResultSet can be wrapped in the DynaBeans by using the ResultSetDynaClass which renders the results of SQL query as series of DynaBeans. The most commonly used collection is java.sql.ResultSet which is returned when JDBC driver uses SQL SELECT statement. The each row of result set can be made visible by using the Commons BeanUtils package.
You can make use of the ResultSetDynaClass by using the DynaBean interface as shown in the below code snippet:
Connection conn = ...; Statement stmt = conn.createStatement(); ResultSet res_set = stmt.executeQuery("select first_name, last_name from student"); Iterator rows = (new ResultSetDynaClass(res_set)).iterator(); while (rows.hasNext()) { DynaBean row = (DynaBean) rows.next(); System.out.println("First Name is:" + row.get("first_name") + " and Last Name is:" + row.get("last_name")); } rs.close(); stmt.close();Advertisements