Java SQL ResultSet Read getObjectByTypeCoercion(ResultSet resultSet, int index, int dataType)

Here you can find the source of getObjectByTypeCoercion(ResultSet resultSet, int index, int dataType)

Description

get Object By Type Coercion

License

Open Source License

Declaration

public static Object getObjectByTypeCoercion(ResultSet resultSet, int index, int dataType) throws SQLException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005, 2010 Sybase, Inc. and others
 * 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://from  w  w w.j  a v a 2  s  . c  o m
 *    Sybase, Inc. - initial API and implementation
 *******************************************************************************/

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

public class Main {
    public static Object getObjectByTypeCoercion(ResultSet resultSet, int index, int dataType) throws SQLException {
        switch (dataType) {
        case Types.TIMESTAMP:
            return resultSet.getTimestamp(index);
        case Types.CLOB:
            return resultSet.getString(index);
        case Types.BLOB:
            return resultSet.getString(index);
        default:
            return resultSet.getObject(index);
        }
    }
}

Related

  1. getNumberColumns(ResultSet rs)
  2. getNumRows(ResultSet query)
  3. getObject(ResultSet resultSet, int columnCount, Map columnLabelMap, String[] fields, String[] columnLabel, Class cls, Boolean flag)
  4. getObject(ResultSet rs, int columnIndex, Class type)
  5. getObject(ResultSet set, int columnIndex)
  6. getOjbClassName(ResultSet rs)
  7. getOptionalInt(ResultSet rs, String name)
  8. getPath(ResultSet r, String columnName)
  9. getRecordsFromResultSet(ResultSet rs)