Java SQL Table Column hasColumn(ResultSet rs, String columnName)

Here you can find the source of hasColumn(ResultSet rs, String columnName)

Description

has Column

License

Apache License

Declaration

public static boolean hasColumn(ResultSet rs, String columnName)
            throws SQLException 

Method Source Code

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

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

public class Main {
    public static boolean hasColumn(ResultSet rs, String columnName)
            throws SQLException {
        ResultSetMetaData rsmd = rs.getMetaData();
        int columns = rsmd.getColumnCount();
        for (int x = 1; x <= columns; x++) {
            if (columnName.equals(rsmd.getColumnName(x))) {
                return true;
            }/*from  w  w w .java 2 s.  co m*/
        }
        return false;
    }
}

Related

  1. getColunmNames(ResultSetMetaData rsmd)
  2. getIndexColumns(Connection connection, String schema, String table, String indexName)
  3. getIndexName(Connection conn, String table, String column)
  4. getRange(Connection C, String table, String column)
  5. hasColumn(final ResultSet row, final String columnName)
  6. hasColumn(ResultSet rs, String columnName)
  7. hasColumn(String columnName, ResultSet resultSet)
  8. hasColumn(String field, ResultSet rs)
  9. hasColumns(Connection conn, String tableName, Collection colNames)