All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sixpointsix.springboot.jdbistarter.resultset.ResultSetDebugger Maven / Gradle / Ivy

package net.sixpointsix.springboot.jdbistarter.resultset;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * Debug the result set
 */
public class ResultSetDebugger {

    /**
     * Get the columns from a result set
     * @param rs result set
     * @return List of column
     * @throws SQLException
     */
    public static List getColumns(ResultSet rs) throws SQLException {
        ResultSetMetaData meta = rs.getMetaData();
        List cols = new ArrayList<>();

        for(int i = 1; i < meta.getColumnCount(); i++) {
            cols.add(meta.getColumnName(i));
        }

        return cols;
    }

    /**
     * Get the columns from a result set
     * @param rsw result set wrapper
     * @return List of column
     * @throws SQLException
     */
    public static List getColumns(ResultSetWrapper rsw) throws SQLException {
        return getColumns(rsw.getResultSet());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy