Java Utililty Methods JDBC Database Metadata

List of utility methods to do JDBC Database Metadata

Description

The list of methods to do JDBC Database Metadata are organized into topic(s).

Method

booleantableExists(Connection connection, String tableName)
table Exists
ResultSet resultSet = null;
try {
    DatabaseMetaData metaData = connection.getMetaData();
    resultSet = metaData.getTables(null, null, tableName, null);
    if (resultSet.next()) {
        return true;
    resultSet = metaData.getTables(null, null, tableName.toUpperCase(), null);
...
booleantableExists(DatabaseMetaData metaData, String tableName)
table Exists
boolean schemaExists;
if (metaData.storesLowerCaseIdentifiers()) {
    tableName = tableName.toLowerCase();
} else if (metaData.storesUpperCaseIdentifiers()) {
    tableName = tableName.toUpperCase();
try (ResultSet rs = metaData.getTables(null, null, tableName, new String[] { "TABLE" })) {
    schemaExists = rs.next();
...
booleantableExists(String tableName, Connection conn)
table Exists
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, null, null, null);
while (rs.next()) {
    if (rs.getString("TABLE_NAME").equalsIgnoreCase(tableName)) {
        return true;
return false;
...
booleantableExists(String tableName, DatabaseMetaData dbm)
table Exists
ResultSet rs = dbm.getTables(null, null, tableName.toUpperCase(), null);
return rs.next();
booleantableIsAccesable(Connection conn, String TableName)
table Is Accesable
int NeedsPrivilege = SELECT_PRIVILEGE | INSERT_PRIVILEGE;
DatabaseMetaData md = conn.getMetaData();
try {
    String me = md.getUserName();
    ResultSet rs = md.getTablePrivileges(null, null, TableName);
    boolean HasResults = false;
    while (rs.next()) {
        HasResults = true;
...