Java SQL Table Column getColumnMetaData(Connection conn, String table, String column)

Here you can find the source of getColumnMetaData(Connection conn, String table, String column)

Description

Helper function for #getColumnType , etc.

License

Open Source License

Declaration

protected static ResultSet getColumnMetaData(Connection conn, String table, String column) throws SQLException 

Method Source Code

//package com.java2s;

import java.sql.Connection;

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

public class Main {
    /**/*w ww .j av a  2 s .  com*/
     * Helper function for {@link #getColumnType}, etc.
     */
    protected static ResultSet getColumnMetaData(Connection conn, String table, String column) throws SQLException {
        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)) {
                return rs;
            }
        }
        throw new SQLException("Table or Column not defined. [table=" + table + ", col=" + column + "].");
    }
}

Related

  1. getAllFromSensorDb( final Connection jdbcConnection, final String tableName, final String orderByColumn)
  2. getColumn(ResultSet result, int col)
  3. getColumnDisplaySize(int col, ResultSetMetaData rsmd)
  4. getColumnIndexFromColumnName(ResultSetMetaData metaData, String columnName)
  5. getColumnLabelMap(ResultSet resultSet)
  6. getColumnName(boolean isShowRowNum, ResultSet rs)
  7. getColumnName(ResultSetMetaData meta, int column)
  8. getColumnNames(final ResultSet resultSet)
  9. getColumnNames(ResultSet resultSet_)