com.github.phantomthief.failover.impl.checker.DataSourceChecker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simple-failover Show documentation
Show all versions of simple-failover Show documentation
A simple failover library for Java
package com.github.phantomthief.failover.impl.checker;
import java.sql.Connection;
import javax.sql.DataSource;
/**
* @author w.vela
*/
public class DataSourceChecker {
public static boolean test(DataSource t) {
try (Connection conn = t.getConnection()) {
return conn != null;
} catch (Throwable e) {
return false;
}
}
}