Class ResultSetUtil

java.lang.Object
org.seppiko.commons.utils.jdbc.ResultSetUtil

public class ResultSetUtil extends Object
JDBC ResultSet Util
Author:
Leonard Woo
  • Method Details

    • convert

      public static ArrayList<HashMap<String,Object>> convert(ResultSet resultSet) throws SQLException
      Convert ResultSet to List of Map (List<Map<ColumnName, ColumnValue>>)
      Parameters:
      resultSet - ResultSet instance. without close.
      Returns:
      List of Map, value type is sql type.
      Throws:
      SQLException - if a database access error occurs or this method is called on a closed result set.
    • convert

      public static <T> ArrayList<T> convert(ResultSet resultSet, Class<T> clazz) throws SQLException, IllegalAccessException
      Convert ResultSet to data object list
      Type Parameters:
      T - data object type.
      Parameters:
      resultSet - ResultSet instance. without close.
      clazz - data object class.
      Returns:
      data object list.
      Throws:
      SQLException - if a database access error occurs or this method is called on a closed result set.
      IllegalAccessException - target object build failed.
    • close

      public static boolean close(ResultSet resultSet) throws SQLException
      Close ResultSet
      Parameters:
      resultSet - ResultSet instance.
      Returns:
      true if ResultSet is closed. false is otherwise.
      Throws:
      SQLException - if a database access error occurs.