Java SQL ResultSet Print printResultSetColumns(ResultSet rs)

Here you can find the source of printResultSetColumns(ResultSet rs)

Description

DOC xqliu Comment method "printResultSetColumns".

License

Open Source License

Parameter

Parameter Description
rs a parameter

Declaration

public static void printResultSetColumns(ResultSet rs) 

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

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

public class Main {
    /**//from www . ja va 2s . c  o  m
     * DOC xqliu Comment method "printResultSetColumns".
     * 
     * @param rs
     */
    public static void printResultSetColumns(ResultSet rs) {
        try {
            ResultSetMetaData metaData = rs.getMetaData();
            int columnSize = metaData.getColumnCount();
            for (int i = 0; i < columnSize; ++i) {
                System.out.println("[" + (i + 1) + "]:" + metaData.getColumnName(i + 1));//$NON-NLS-1$//$NON-NLS-2$
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. printResultSet(ResultSet rs)
  2. printResultSet(ResultSet rs)
  3. printResultSet(ResultSet rs)
  4. printResultSet(ResultSet rs)
  5. printResultSet(ResultSet rs)
  6. printResultSetHeader(ResultSet rs)
  7. printResultSetMetadata(ResultSetMetaData rsmd, Writer out)
  8. printResultSetRow(ResultSet rs)
  9. printResultsToFile(ResultSet rst, File outFile)