public static Object getValueByColumnType ( final ResultSet resultSet , final int columnIndex ) throws SQLException { ResultSetMetaData metaData = resultSet . getMetaData ( ) ; switch ( metaData . getColumnType ( columnIndex ) ) { case Types . BIT : case Types . BOOLEAN : return resultSet . getBoolean ( columnIndex ) ; case Types . TINYINT : return resultSet . getByte ( columnIndex ) ; case Types . SMALLINT : return resultSet . getShort ( columnIndex ) ; case Types . INTEGER : return resultSet . getInt ( columnIndex ) ; case Types . BIGINT : return resultSet . getLong ( columnIndex ) ; case Types . NUMERIC : case Types . DECIMAL : return resultSet . getBigDecimal ( columnIndex ) ; case Types . FLOAT : case Types . DOUBLE : return resultSet . getDouble ( columnIndex ) ; case Types . CHAR : case Types . VARCHAR : case Types . LONGVARCHAR : return resultSet . getString ( columnIndex ) ; case Types . BINARY : case Types . VARBINARY : case Types . LONGVARBINARY : return resultSet . getBytes ( columnIndex ) ; case Types . DATE : return resultSet . getDate ( columnIndex ) ; case Types . TIME : return resultSet . getTime ( columnIndex ) ; case Types . TIMESTAMP : return resultSet . getTimestamp ( columnIndex ) ; case Types . CLOB : return resultSet . getClob ( columnIndex ) ; case Types . BLOB : return resultSet . getBlob ( columnIndex ) ; default : return resultSet . getObject ( columnIndex ) ; } }
Get value by column type .