List of utility methods to do SQL ResultSet Read
ArrayList | getListMapFromResultSet(ResultSet rs) get List Map From Result Set ArrayList<Map<String, String>> myList = new ArrayList<Map<String, String>>(); try { while (rs.next()) { Map<String, String> map = new HashMap<String, String>(); ResultSetMetaData rsmd = rs.getMetaData(); int numColumns = rsmd.getColumnCount(); for (int i = 1; i < numColumns + 1; i++) { String columnName = rsmd.getColumnName(i); ... |
LocalDate | getLocalDate(ResultSet res, String name) get Local Date return LocalDate.parse(res.getString(name), tarmedFormatter);
|
LocalDate | getLocalDate(ResultSet rs, String columnName) Get LocalDate instance from the ResultSet rs with columnName Date sqlDate = rs.getDate(columnName);
return sqlDate == null ? null : sqlDate.toLocalDate();
|
Map | getMap(ResultSet resultSet) get Map Map<String, Object> valueMap = new HashMap<String, Object>(); try { ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); for (int j = 1; j <= columnCount; j++) { valueMap.put(metaData.getColumnLabel(j), resultSet.getObject(j)); } catch (SQLException e) { ... |
Map | getMap(ResultSet resultSet) Returns next record of result set as a Map. ResultSetMetaData metaData = resultSet.getMetaData(); int cols = metaData.getColumnCount(); HashMap row = new HashMap(cols, 1); if (resultSet.next()) { for (int i = 1; i <= cols; i++) { row.put(metaData.getColumnName(i), resultSet.getObject(i)); return ((Map) row); |
Map | getMap(ResultSet rs, ResultSetMetaData metaData, int cols_len) get Map Map<String, Object> map = new LinkedHashMap<String, Object>(); for (int i = 0; i < cols_len; i++) { String cols_name = metaData.getColumnLabel(i + 1); Object cols_value = getValueByObjectType(metaData, rs, i); map.put(cols_name, cols_value); return map; |
ResultSetMetaData | getMetaData(ResultSet rs) get Meta Data ResultSetMetaData rsmd = rs.getMetaData();
return rsmd;
|
T | getNullable(final ResultSet resultSet, final T value) Returns the given value or null if the last column lookup resulted in a null value. return resultSet.wasNull() ? null : value;
|
Boolean | getNullableBooleanFromResultSet(ResultSet rset, Enum field) get Nullable Boolean From Result Set return getNullableBooleanFromResultSet(rset, field.name());
|
Byte | getNullableByte(ResultSet resultSet, String columnLabel) Returns the value of the specified column from the ResultSet or null if the value is nullable and was null. byte value = resultSet.getByte(columnLabel); return resultSet.wasNull() ? null : value; |