Java SQL Table Column getColumnValueFromResultSet(int columnIndex, int argType, ResultSet rs)

Here you can find the source of getColumnValueFromResultSet(int columnIndex, int argType, ResultSet rs)

Description

get Column Value From Result Set

License

Open Source License

Declaration

public static Object getColumnValueFromResultSet(int columnIndex, int argType, ResultSet rs)
        throws SQLException 

Method Source Code

//package com.java2s;

import java.sql.ResultSet;
import java.sql.SQLException;

import java.sql.Types;

public class Main {

    public static Object getColumnValueFromResultSet(int columnIndex, int argType, ResultSet rs)
            throws SQLException {
        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:
            return new Double(rs.getDouble(columnIndex));
        case Types.CHAR:
        case Types.VARCHAR:
            return rs.getString(columnIndex);
        case Types.DATE:
            return rs.getDate(columnIndex);
        case Types.TIMESTAMP:
            return rs.getTimestamp(columnIndex);
        default:// w w w. j  a v a 2  s.co m
            return rs.getObject(columnIndex);
        }
    }
}

Related

  1. getColumnType(ResultSetMetaData rsm)
  2. getColumnType(ResultSetMetaData rsmd, int idx)
  3. getColumnTypes(ResultSet rs)
  4. getColumnValue(ResultSet rs, ResultSetMetaData rsmd, int colIndex)
  5. getColumnValue(String column, String defaultValue, Map columnIndexMap, ResultSet res)
  6. getColunmNames(ResultSetMetaData rsmd)
  7. getIndexColumns(Connection connection, String schema, String table, String indexName)
  8. getIndexName(Connection conn, String table, String column)
  9. getRange(Connection C, String table, String column)