बस जांचें कि क्या Class#forName() JDBC ड्राइवर पर ClassNotFoundException नहीं फेंकता ।
try {
Class.forName(driverClassName);
// Success.
}
catch (ClassNotFoundException e) {
// Fail.
}
बस जांचें कि क्या DriverManager#getConnection() या DataSource#getConnection() SQLException नहीं फेंकता ।
try (Connection connection = DriverManager.getConnection(url, username, password)) {
// Success.
}
catch (SQLException e) {
// Fail.
}