Java SQL ResultSet loadMap(final ResultSet rs)

Here you can find the source of loadMap(final ResultSet rs)

Description

load Map

License

Open Source License

Declaration

public static Map<String, Object> loadMap(final ResultSet rs)
        throws SQLException, IllegalAccessException, InvocationTargetException 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Product: ADempiereLBR - ADempiere Localization Brazil                      *
 * This program is free software; you can redistribute it and/or modify it    *
 * under the terms version 2 of the GNU General Public License as published   *
 * by the Free Software Foundation. This program 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 General Public License for more details.                       *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.                     *
 *****************************************************************************/

import java.lang.reflect.InvocationTargetException;

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

import java.util.HashMap;

import java.util.Map;

public class Main {

    public static Map<String, Object> loadMap(final ResultSet rs)
            throws SQLException, IllegalAccessException, InvocationTargetException {

        int columnCount = rs.getMetaData().getColumnCount();
        String columnName = null;
        Object columnValue = null;
        Map<String, Object> fieldValue = new HashMap<String, Object>();

        for (int column = 1; column <= columnCount; column++) {
            columnName = rs.getMetaData().getColumnName(column);
            columnValue = rs.getObject(column);
            fieldValue.put(columnName, columnValue);
        }/*from w w w .jav  a2 s.  c  o  m*/

        return fieldValue;
    }
}

Related

  1. isNull(ResultSet rs, String name)
  2. isResultEmpty(ResultSet theResult)
  3. isReturnsInvalidResultSetException(SQLException se)
  4. isSupportedResultSetType(Connection connection, int resultSetType)
  5. loadListMap(final ResultSet rs)
  6. logCurrentResultSetRow(Log log, String msg, ResultSet rs)
  7. mapResultSet(ResultSet set)
  8. moveToPageNo(ResultSet rs, int pageNo, int pageSize)
  9. parseSqlResultToListMap(ResultSet rs)