List of utility methods to do JDBC Database Metadata
boolean | tableExists(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); ... |
boolean | tableExists(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(); ... |
boolean | tableExists(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; ... |
boolean | tableExists(String tableName, DatabaseMetaData dbm) table Exists ResultSet rs = dbm.getTables(null, null, tableName.toUpperCase(), null);
return rs.next();
|
boolean | tableIsAccesable(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; ... |