Java SQL ResultSet to toObjectArray(ResultSet resultSet)

Here you can find the source of toObjectArray(ResultSet resultSet)

Description

to Object Array

License

Open Source License

Declaration

public static Object[] toObjectArray(ResultSet resultSet) throws SQLException 

Method Source Code

//package com.java2s;
/*// ww  w .j a v a 2s .  co  m
 * Copyright 2015 The Solmix Project
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.gnu.org/licenses/ 
 * or see the FSF site: http://www.fsf.org. 
 */

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

public class Main {
    public static Object[] toObjectArray(ResultSet resultSet) throws SQLException {
        ResultSetMetaData rsmd = resultSet.getMetaData();
        int count = rsmd.getColumnCount();
        Object[] result = new Object[count];
        for (int colCursor = 1; colCursor <= count; colCursor++) {
            Object obj = resultSet.getObject(colCursor);
            result[colCursor - 1] = obj;
        }
        return result;
    }
}

Related

  1. toListMap(int limit, ResultSet rs)
  2. toMap(final ResultSet resultSet)
  3. toMap(final ResultSet resultSet)
  4. toMapList(ResultSet rs)
  5. toMapOfLists(ResultSet rs)
  6. toSingleResult(ResultSet rs)