Here you can find the source of hasColumn(final ResultSet row, final String columnName)
Parameter | Description |
---|---|
row | A result set |
columnName | A column name |
Parameter | Description |
---|---|
SQLException | If there is a problem accessing the result set |
public static boolean hasColumn(final ResultSet row, final String columnName) throws SQLException
//package com.java2s; //License from project: Educational Community License import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { /**/* ww w. j av a 2 s . c o m*/ * Test if a column name exists within the given result set. * * @param row A result set * @param columnName A column name * @return True if the column name exists in the given result set * @throws SQLException If there is a problem accessing the result set */ public static boolean hasColumn(final ResultSet row, final String columnName) throws SQLException { final ResultSetMetaData metaData = row.getMetaData(); for (int i = 1; i <= metaData.getColumnCount(); i++) { final String name = metaData.getColumnName(i); if (columnName.equals(name)) return true; } return false; } }