View Javadoc

    1   package sharin.sql.runner.processor;
    2
    3   import java.sql.ResultSet;
    4   import java.sql.ResultSetMetaData;
    5
    6   import sharin.sql.runner.ResultSetProcessor;
    7   import sharin.util.SqlUtils;
    8
    9   public class ArrayResultSetProcessor implements ResultSetProcessor {
    10
    11      public Integer prepare(ResultSet rs) {
    12          ResultSetMetaData metaData = SqlUtils.getMetaData(rs);
    13          return SqlUtils.getColumnCount(metaData);
    14      }
    15
    16      public Object process(ResultSet rs, Object context) {
    17          int count = (Integer) context;
    18          Object[] result = new Object[count];
    19
    20          for (int i = 0; i < count; i++) {
    21              result[i] = SqlUtils.getObject(rs, i + 1);
    22          }
    23
    24          return result;
    25      }
    26  }