Java Utililty Methods SQL ResultSet String Read

List of utility methods to do SQL ResultSet String Read

Description

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

Method

StringgetString(ResultSet p_rset, int p_col)
static method for handling positional column gets for String values
try {
    return p_rset.getString(p_col);
} catch (SQLException e_sql) {
    return null;
StringgetString(ResultSet res, String name)
Returns the values of the specified column as a String.
String v = res.getString(name);
return res.wasNull() ? null : v;
StringgetString(ResultSet resultSet, String columnName)
Returns a string value using a given SQL result set and column name.
String value = null;
if (resultSet != null && columnName != null) {
    value = resultSet.getString(columnName);
return value;
StringgetString(ResultSet resultSet, String columnName)
get String
String value = null;
if (checkColumn(resultSet, columnName))
    value = resultSet.getString(columnName);
return value;
StringgetString(ResultSet rs, int index, boolean trim)
get String
String result = rs.getString(index);
if (trim && result != null) {
    return result.trim();
return result;
StringgetString(ResultSet rs, int ix, int sql_type)
get String
switch (sql_type) {
case Types.DATE:
    Date date = rs.getDate(ix);
    if (date == null)
        return null;
    return df_date.format(date);
case Types.TIMESTAMP:
    Timestamp timestamp = rs.getTimestamp(ix);
...
StringgetString(ResultSet rs, String column)
ResultSets often come with "NULL" and return nulls, we preferr actual objects with appropriate values.
String t = rs.getString(column);
if (rs.wasNull())
    t = "";
return t;
StringgetString(ResultSet rs, String columnLabel)
get String
return rs.getString(columnLabel);
StringgetString(ResultSet rs, String columnName)
get String
String s = rs.getString(columnName);
return rs.wasNull() ? null : s;
StringgetString(ResultSet rs, String name)
get String
try {
    return "\"" + name + "\":\"" + escapeQuotes(rs.getString(name)) + "\"";
} catch (SQLException ex) {
    return "\"" + name + "\":\"error\"";