Package ch.inftec.ju.db.DbRowUtils

Examples of ch.inftec.ju.db.DbRowUtils.DbRowsImpl


*/
class DbRowResultSetHandler implements ResultSetHandler<DbRowsImpl> {

  @Override
  public DbRowsImpl handle(ResultSet rs) throws SQLException {
    DbRowsImpl dbRows = new DbRowsImpl();
   
    ResultSetMetaData rsmd = rs.getMetaData();
    while (rs.next()) {
      if (rsmd == null) rsmd = rs.getMetaData();
     
      DbRowBuilder rowBuilder = DbRowUtils.newDbRow();
      for (int i = 1; i <= rsmd.getColumnCount(); i++) {
        rowBuilder.addValue(rsmd.getColumnName(i), rsmd.getColumnType(i), this.processValue(rs.getObject(i)));
      }
      dbRows.addRow(rowBuilder.getRow());
    }
   
    // Set base row if query yielded no rows
    if (dbRows.getRowCount() == 0) {
      DbRowBuilder rowBuilder = DbRowUtils.newDbRow();
      for (int i = 1; i <= rsmd.getColumnCount(); i++) {
        rowBuilder.addValue(rsmd.getColumnName(i), rsmd.getColumnType(i), null);
      }
      dbRows.setBaseRow(rowBuilder.getRow());
    }
   
    return dbRows;
  }
View Full Code Here

TOP

Related Classes of ch.inftec.ju.db.DbRowUtils.DbRowsImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.