Here you can find the source of hasColumn(String columnName, ResultSet resultSet)
public static boolean hasColumn(String columnName, ResultSet resultSet)
//package com.java2s; /*//from ww w. j a v a2 s . c om * Copyright (c) 2012, Mayocat <hello@mayocat.org> * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static boolean hasColumn(String columnName, ResultSet resultSet) { ResultSetMetaData meta = null; try { meta = resultSet.getMetaData(); int columnCount = meta.getColumnCount(); for (int i = 1; i < columnCount + 1; i++) { if (meta.getColumnName(i).equals(columnName)) { return true; } } } catch (SQLException e) { // Ignore } return false; } }