Java SQL ResultSet Read getValue(int type, ResultSet resultSet, int columnIndex)

Here you can find the source of getValue(int type, ResultSet resultSet, int columnIndex)

Description

get Value

License

Open Source License

Declaration

private static Object getValue(int type, ResultSet resultSet, int columnIndex) throws SQLException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Oobium, Inc./*w  ww .j av  a2 s.  c  om*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Jeremy Dowdall <jeremy@oobium.com> - initial API and implementation
 ******************************************************************************/

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Types;

public class Main {
    private static Object getValue(int type, ResultSet resultSet, int columnIndex) throws SQLException {
        switch (type) {
        case Types.BLOB:
            return resultSet.getBytes(columnIndex);
        case Types.CLOB:
            return resultSet.getString(columnIndex);
        default:
            return resultSet.getObject(columnIndex);
        }
    }

    public static Object getValue(ResultSet resultSet, int columnIndex) throws SQLException {
        return getValue(resultSet.getMetaData().getColumnType(columnIndex), resultSet, columnIndex);
    }
}

Related

  1. getRSData(ResultSet rs, String columnName, int jdbcType)
  2. getStatement(ResultSet resultSet)
  3. getURI(ResultSet resultSet, String columnLabel)
  4. getURI(ResultSet rs, int col)
  5. getUUIDFromResultSet(ResultSet rset, String name)
  6. getValue(ResultSet result, String strField)
  7. getValue(ResultSet resultSet, String columnName, E defaultValue)
  8. getValue(ResultSet rs, String sField)
  9. getValue4Type(ResultSet rs, String column, Class typeClass)