Java SQL ResultSet encodeHeader(ResultSetMetaData metaData)

Here you can find the source of encodeHeader(ResultSetMetaData metaData)

Description

encode Header

License

Apache License

Declaration

public static List<String> encodeHeader(ResultSetMetaData metaData) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> encodeHeader(ResultSetMetaData metaData) throws SQLException {
        ArrayList<String> res = new ArrayList<>();
        res.add(Integer.toString(metaData.getColumnCount()));
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            String columnName = metaData.getColumnName(i);
            String columnLabel = metaData.getColumnLabel(i);
            if (columnLabel == null || columnLabel.equalsIgnoreCase(columnName)) {
                res.add(columnName);/*from w  ww  .j a v  a  2  s.  c  o  m*/
            } else {
                res.add(String.format("%s/%s", columnName, columnLabel));
            }
            res.add(metaData.getColumnTypeName(i));
            res.add(Integer.toString(metaData.getColumnType(i)));
            res.add(Integer.toString(metaData.getPrecision(i)));
            res.add(Integer.toString(metaData.getScale(i)));
        }

        return res;
    }
}

Related

  1. copyInt(ResultSet rs, int sourcePos, PreparedStatement stmt, int destPos)
  2. createLargeResultSetPreparedStatement(Connection conn, String sql)
  3. createLargeResultSetStatement(Connection conn)
  4. createTable(ResultSet rs)
  5. createUid(final String[] keys, final ResultSet rs, final String keySeparator)
  6. extractGeneratedId(ResultSet generatedKeys)
  7. extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index)
  8. extractResults(ResultSet resultSet)
  9. extractResultSetFiledNames(ResultSet result)