|
|
|
@ -7,7 +7,6 @@ import org.xbib.jdbc.query.util.Metric;
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
import java.io.Closeable;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
@ -313,14 +312,37 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
|
|
|
|
|
} finally {
|
|
|
|
|
metric.done();
|
|
|
|
|
if (logger.isLoggable(Level.FINE)) {
|
|
|
|
|
StringBuilder buf = new StringBuilder("Get ").append(builder.options.flavor()).append(" database: ");
|
|
|
|
|
metric.printMessage(buf);
|
|
|
|
|
logger.fine(buf.toString());
|
|
|
|
|
StringBuilder sb = new StringBuilder("Get ").append(builder.options.flavor()).append(" database: ");
|
|
|
|
|
metric.printMessage(sb);
|
|
|
|
|
logger.fine(sb.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean check() {
|
|
|
|
|
Metric metric = new Metric(logger.isLoggable(Level.FINE));
|
|
|
|
|
boolean probe = false;
|
|
|
|
|
try {
|
|
|
|
|
if (database != null) {
|
|
|
|
|
probe = database.probe();
|
|
|
|
|
} else {
|
|
|
|
|
get();
|
|
|
|
|
probe = database.probe();
|
|
|
|
|
}
|
|
|
|
|
} catch (SQLException | RuntimeException e) {
|
|
|
|
|
metric.checkpoint("fail", e.getMessage());
|
|
|
|
|
} finally {
|
|
|
|
|
metric.done();
|
|
|
|
|
if (logger.isLoggable(Level.FINE)) {
|
|
|
|
|
StringBuilder sb = new StringBuilder("Probe ").append(builder.options.flavor()).append(" database: ");
|
|
|
|
|
metric.printMessage(sb);
|
|
|
|
|
logger.log(Level.FINE, sb.toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return probe;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void commit() {
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
try {
|
|
|
|
|