Java SQL ResultSet Read getArray(ResultSet rs, String columnName, Class cls)

Here you can find the source of getArray(ResultSet rs, String columnName, Class cls)

Description

get Array

License

Open Source License

Declaration

public static <T> T[] getArray(ResultSet rs, String columnName, Class<? extends T[]> cls) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Array;

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

import java.util.Arrays;

public class Main {
    public static <T> T[] getArray(ResultSet rs, String columnName, Class<? extends T[]> cls) throws SQLException {
        return getArray(rs, columnName, cls, null);
    }//from  w  w w.java 2s.c  o  m

    public static <T> T[] getArray(ResultSet rs, String columnName, Class<? extends T[]> cls, T[] ifNull)
            throws SQLException {
        Array array = rs.getArray(columnName);
        if (array != null) {
            Object[] objects = (Object[]) array.getArray();
            return Arrays.copyOf(objects, objects.length, cls);
        } else {
            return ifNull;
        }
    }
}

Related

  1. getAllData(ResultSet rs)
  2. getAllRow(ResultSet rs)
  3. getAllValueMaps(ResultSet input)
  4. getArray(ResultSet resultSet, String columnLabel, Class clazz)
  5. getArray(ResultSet rs, int index)
  6. getArrayAsSet(ResultSet rs, String columnLabel)
  7. getArrayFromResultSet(ResultSet rs, String field)
  8. getAsString(ResultSet res, String field)
  9. getBestRowId(String schema, String tableName, int scope, String nullable, ResultSet[] rs)