Stačí zkontrolovat, zda Class#forName()
na ovladači JDBC nevyvolá ClassNotFoundException
.
try {
Class.forName(driverClassName);
// Success.
}
catch (ClassNotFoundException e) {
// Fail.
}
Stačí zkontrolovat, zda DriverManager#getConnection()
nebo DataSource#getConnection()
nevyvolá SQLException
.
try (Connection connection = DriverManager.getConnection(url, username, password)) {
// Success.
}
catch (SQLException e) {
// Fail.
}