Java Utililty Methods SQL Table Column

List of utility methods to do SQL Table Column

Description

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

Method

String[]getColumns(ResultSetMetaData rsmd)
Returns an array of strings as upper-case column names.
String[] names = new String[rsmd.getColumnCount()];
for (int i = 0; i < rsmd.getColumnCount(); i++) {
    names[i] = rsmd.getColumnName(i + 1);
return names;
String[]getColumns(ResultSetMetaData rsMetaData)
get Columns
int colcount = rsMetaData.getColumnCount();
String[] result = new String[colcount];
for (int i = 0; i < result.length; i++) {
    result[i] = rsMetaData.getColumnName(i + 1);
return result;
String[]getColumnsNames(ResultSet rs)
get Columns Names
String[] columnNames = null;
try {
    ResultSetMetaData rsmd = rs.getMetaData();
    List<String> lstColumnNames = new ArrayList<String>();
    for (int i = 0; i < rsmd.getColumnCount(); i++) {
        lstColumnNames.add(rsmd.getColumnName(i));
    columnNames = new String[lstColumnNames.size()];
...
intgetColumnType(ResultSet resultSet, int i, Map typeCache)
Gets type of column from result-set.
Integer type = typeCache.get(i);
if (type == null) {
    try {
        type = resultSet.getMetaData().getColumnType(i);
    } catch (Exception e) {
        type = Types.OTHER;
    typeCache.put(i, type);
...
MapgetColumnType(ResultSetMetaData rsm)
get column type
return getColumnType(false, rsm);
StringgetColumnType(ResultSetMetaData rsmd, int idx)

Get the type of an external database's column as a Derby type name.

int jdbcType = rsmd.getColumnType(idx);
int precision = rsmd.getPrecision(idx);
int scale = rsmd.getScale(idx);
switch (jdbcType) {
case Types.BIGINT:
    return "bigint";
case Types.BINARY:
    return "char " + precisionToLength(precision) + "  for bit data";
...
int[]getColumnTypes(ResultSet rs)
Determines the SQL column types used in the provided resultset.
return getColumnTypes(rs.getMetaData());
StringgetColumnValue(ResultSet rs, ResultSetMetaData rsmd, int colIndex)
get Column Value
String s = rs.getString(colIndex);
if (rs.wasNull())
    return "null";
switch (rsmd.getColumnType(colIndex)) {
case Types.BIT: 
    if (s.equals("t") || s.equals("f"))
        return String.valueOf(rs.getBoolean(colIndex));
    else
...
StringgetColumnValue(String column, String defaultValue, Map columnIndexMap, ResultSet res)
get Column Value
int index = columnIndexMap.containsKey(column.toUpperCase()) ? columnIndexMap.get(column.toUpperCase())
        : -1;
if (index > -1) {
    String str;
    try {
        Object obj = res.getObject(index);
        if (obj == null) {
            return null;
...
ObjectgetColumnValueFromResultSet(int columnIndex, int argType, ResultSet rs)
get Column Value From Result Set
switch (argType) {
case Types.INTEGER:
    return new Integer(rs.getInt(columnIndex));
case Types.BOOLEAN:
    return new Boolean(rs.getBoolean(columnIndex));
case Types.FLOAT:
    return new Float(rs.getFloat(columnIndex));
case Types.DOUBLE:
...