Java Utililty Methods SQL ResultSet

List of utility methods to do SQL ResultSet

Description

The list of methods to do SQL ResultSet are organized into topic(s).

Method

booleanisResultEmpty(ResultSet theResult)
is Result Empty
if (!theResult.isBeforeFirst()) {
    return true;
return false;
booleanisReturnsInvalidResultSetException(SQLException se)
is Returns Invalid Result Set Exception
if ((se.getMessage() != null
        && se.getMessage().indexOf("cannot be called with a statement that returns a ResultSet.") >= 0)
        || (se.getSQLState() != null && (se.getSQLState().equals("X0Y79"))))
    return true;
return false;
booleanisSupportedResultSetType(Connection connection, int resultSetType)
is Supported Result Set Type
DatabaseMetaData dbmd = connection.getMetaData();
return dbmd.supportsResultSetType(resultSetType);
List>loadListMap(final ResultSet rs)
load List Map
List<Map<?, ?>> list = new ArrayList<Map<?, ?>>();
while (rs.next()) {
    list.add(loadMap(rs));
return list;
voidlogCurrentResultSetRow(Log log, String msg, ResultSet rs)
log Current Result Set Row
if (log.isDebugEnabled()) {
    ResultSetMetaData rsmd = rs.getMetaData();
    if (msg != null) {
        log.debug(msg);
    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
        log.debug("  " + rsmd.getColumnName(i) + " (" + rsmd.getColumnClassName(i) + ") = "
                + rs.getString(i));
...
MapmapResultSet(ResultSet set)
map Result Set
Map<String, Object> map = new HashMap<String, Object>();
ResultSetMetaData m = set.getMetaData();
int columnCount = m.getColumnCount();
for (int i = 0; i < columnCount; i++) {
    map.put(m.getColumnName(i), set.getObject(i));
return map;
voidmoveToPageNo(ResultSet rs, int pageNo, int pageSize)
The result set cursor move to current page number.
if (pageNo > 1) {
    int row = (pageNo - 1) * pageSize;
    rs.absolute(row);
ListparseSqlResultToListMap(ResultSet rs)
parse Sql Result To List Map
List<Object> list = new ArrayList<Object>();
ResultSetMetaData metaData = rs.getMetaData();
int cols_len = metaData.getColumnCount();
while (rs.next()) {
    list.add(getMap(rs, metaData, cols_len));
if (list.size() == 0) {
    return null;
...
voidputResultSetToMap(final Hashtable map, final ResultSet resultSet, final String... keys)
Put all the keys from the resultSet into the map using the specified keys.
for (String key : keys) {
    String val = resultSet.getString(key);
    if (val != null) {
        map.put(key, val);
StringsafeGetString(ResultSet r, String name)
safe Get String
String s = r.getString(name);
return (s != null) ? s : EMPTY;