// Get column meta data from the database
public static ResultSet getColumnData(final Connection conn, final String tableName, final String columnName) {
ResultSet rs = null;
try {
if (conn != null && meta == null) {
meta = conn.getMetaData();
}
rs = meta.getColumns(conn.getCatalog(), null, tableName, columnName);
} catch (SQLException e) {
logger.error("Exception occured while getting column meta data", e);
}
return rs;
}
// Get column size from the column meta data
public static int getColumnSize(final Connection conn, final String tableName, final String columnName) {
int columnSize = 0;
try {
ResultSet rs = getColumnData(conn, tableName, columnName);
if (rs != null) {
columnSize = rs.getInt("COLUMN_SIZE");
}
} catch (SQLException e) {
logger.error("Exception occured while getting column size", e);
}
return columnSize;
}
public static ResultSet getColumnData(final Connection conn, final String tableName, final String columnName) {
ResultSet rs = null;
try {
if (conn != null && meta == null) {
meta = conn.getMetaData();
}
rs = meta.getColumns(conn.getCatalog(), null, tableName, columnName);
} catch (SQLException e) {
logger.error("Exception occured while getting column meta data", e);
}
return rs;
}
// Get column size from the column meta data
public static int getColumnSize(final Connection conn, final String tableName, final String columnName) {
int columnSize = 0;
try {
ResultSet rs = getColumnData(conn, tableName, columnName);
if (rs != null) {
columnSize = rs.getInt("COLUMN_SIZE");
}
} catch (SQLException e) {
logger.error("Exception occured while getting column size", e);
}
return columnSize;
}