Cukup periksa apakah Class#forName()
pada driver JDBC tidak membuang ClassNotFoundException
.
try {
Class.forName(driverClassName);
// Success.
}
catch (ClassNotFoundException e) {
// Fail.
}
Cukup periksa apakah DriverManager#getConnection()
atau DataSource#getConnection()
tidak membuang SQLException
.
try (Connection connection = DriverManager.getConnection(url, username, password)) {
// Success.
}
catch (SQLException e) {
// Fail.
}