List of utility methods to do SQL ResultSet Read
T | get(ResultSet rs, String name) get try { return (T) rs.getObject(name); } catch (SQLException e) { return null; |
List | getAllColumnNames(ResultSet rs) get All Column Names List<String> columnNames = new ArrayList<String>(); if (null != rs) { for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) { columnNames.add(rs.getMetaData().getColumnName(i + 1)); return columnNames; |
String[] | getAllColumnNamesFromResultSet(ResultSet set) Returns the names of the columns in a ResultSet in the order that they appear in the result. ResultSetMetaData md = set.getMetaData(); String[] out = new String[md.getColumnCount()]; for (int i = 0; i < out.length; i++) out[i] = md.getColumnName(i + 1); return out; |
Object[][] | getAllData(ResultSet rs) get All Data return getAllData(rs, true);
|
String[][] | getAllRow(ResultSet rs) Return all rows in String[][] based on result set return getAllRow(rs, -1);
|
List | getAllValueMaps(ResultSet input) Get a List of Maps containing the rows of the ResultSet with a matching valid date information. List<Map<String, String>> ret = new ArrayList<Map<String, String>>(); ArrayList<String> headers = new ArrayList<String>(); ResultSetMetaData meta = input.getMetaData(); int metaLength = meta.getColumnCount(); for (int i = 1; i <= metaLength; i++) { headers.add(meta.getColumnName(i)); while (input.next()) { ... |
T[] | getArray(ResultSet resultSet, String columnLabel, Class get Array @SuppressWarnings("unchecked") T[] array = (T[]) resultSet.getArray(columnLabel).getArray(); if (array != null) { return array; @SuppressWarnings("unchecked") T[] empty = (T[]) Array.newInstance(clazz, 0); return empty; ... |
List | getArray(ResultSet rs, int index) get Array List<T> ret = new LinkedList<T>(); Array value = rs.getArray(index); if (value != null) { for (T e : (T[]) value.getArray()) { ret.add(e); return ret; ... |
T[] | getArray(ResultSet rs, String columnName, Class extends T[]> cls) get Array return getArray(rs, columnName, cls, null);
|
Set | getArrayAsSet(ResultSet rs, String columnLabel) Returns a string set for the given result set and column. Array sqlArray = rs.getArray(columnLabel);
String[] array = (String[]) sqlArray.getArray();
return Sets.newHashSet(array);
|