public static List<String> getColumnNameList(final Connection conn, final String tableName) throws SQLException {
        final String query = "SELECT * FROM " + tableName + " WHERE 1 > 2";
        PreparedStatement stmt = null;
        ResultSet rs = null;

        try {
            stmt = prepareStatement(conn, query);
            rs = stmt.executeQuery();

            final ResultSetMetaData metaData = rs.getMetaData();
            final int columnCount = metaData.getColumnCount();
            final List<String> columnNameList = new ArrayList<>(columnCount);

            for (int i = 1, n = columnCount + 1; i < n; i++) {
                columnNameList.add(metaData.getColumnName(i));
            }

            return columnNameList;
        } finally {
            closeQuietly(rs, stmt);
        }
    }
public static List < String > getColumnNameList ( final Connection conn , final String tableName ) throws SQLException { final String query = "SELECT * FROM " + tableName + " WHERE 1 > 2" ; PreparedStatement stmt = null ; ResultSet rs = null ; try { stmt = prepareStatement ( conn , query ) ; rs = stmt . executeQuery ( ) ; final ResultSetMetaData metaData = rs . getMetaData ( ) ; final int columnCount = metaData . getColumnCount ( ) ; final List < String > columnNameList = new ArrayList < > ( columnCount ) ; for ( int i = 1 , n = columnCount + 1 ; i < n ; i ++ ) { columnNameList . add ( metaData . getColumnName ( i ) ) ; } return columnNameList ; } finally { closeQuietly ( rs , stmt ) ; } }
@param conn
@param tableName
@return
@throws SQLException