Here you can find the source of tableContainsColumn(Connection conn, String table, String column)
public static boolean tableContainsColumn(Connection conn, String table, String column) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; public class Main { /**/* www. j a v a 2s. co m*/ * Returns true if the table with the specified name exists and contains a column with the * specified name, false if either condition does not hold true. <em>Note:</em> the names are * case sensitive. */ public static boolean tableContainsColumn(Connection conn, String table, String column) throws SQLException { boolean matched = false; ResultSet rs = conn.getMetaData().getColumns("", "", table, column); while (rs.next()) { String tname = rs.getString("TABLE_NAME"); String cname = rs.getString("COLUMN_NAME"); if (tname.equals(table) && cname.equals(column)) { matched = true; } } return matched; } }