use of java.sql.DatabaseMetaData in project dubbo by alibaba.
the class DatabaseStatusChecker method check.
public Status check() {
boolean ok;
try {
Connection connection = dataSource.getConnection();
try {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet resultSet = metaData.getTypeInfo();
try {
ok = resultSet.next();
} finally {
resultSet.close();
}
if (message == null) {
message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
}
if (version == 0) {
version = metaData.getDatabaseMajorVersion();
}
} finally {
connection.close();
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
ok = false;
}
return new Status(!ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}
use of java.sql.DatabaseMetaData in project dubbo by alibaba.
the class DatabaseStatusChecker method check.
public Status check() {
boolean ok;
try {
Connection connection = dataSource.getConnection();
try {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet resultSet = metaData.getTypeInfo();
try {
ok = resultSet.next();
} finally {
resultSet.close();
}
if (message == null) {
message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
}
if (version == 0) {
version = metaData.getDatabaseMajorVersion();
}
} finally {
connection.close();
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
ok = false;
}
return new Status(!ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}
use of java.sql.DatabaseMetaData in project druid by alibaba.
the class ConnectionProxyImpl method getMetaData.
@Override
public DatabaseMetaData getMetaData() throws SQLException {
FilterChainImpl chain = createChain();
DatabaseMetaData value = chain.connection_getMetaData(this);
recycleFilterChain(chain);
return value;
}
use of java.sql.DatabaseMetaData in project GNS by MobilityFirst.
the class SimpleKeyStore method tableExists.
private boolean tableExists(String name) {
try {
DatabaseMetaData dbm = conn.getMetaData();
ResultSet resultSet = dbm.getTables(null, null, name, null);
return resultSet.next();
} catch (SQLException e) {
DerbyControl.printSQLException(e);
return false;
}
}
use of java.sql.DatabaseMetaData in project GNS by MobilityFirst.
the class SimpleKeyStore method showAllTables.
private void showAllTables() {
try {
DatabaseMetaData meta = conn.getMetaData();
ResultSet resultSet = meta.getColumns(null, null, null, null);
while (resultSet.next()) {
if (!resultSet.getString("TABLE_NAME").startsWith("SYS")) {
GNSClientConfig.getLogger().log(Level.FINE, "TABLE: {0}", resultSet.getString("TABLE_NAME"));
}
}
} catch (SQLException e) {
DerbyControl.printSQLException(e);
}
}
Aggregations