How do I check whether a driver is JDBC compliant?

package org.kodejava.example.sql;

import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcCompliant {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost/kodejavadb";
            Driver driver = DriverManager.getDriver(url);

            //
            // Check if the driver is a genuine JDBC compliant driver.
            //
            if (driver.jdbcCompliant()) {
                System.out.println("A genuine JDBC compliant driver");
            } else {
                System.out.println("Not a genuine JDBC compliant driver");
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
Wayan Saryada

Wayan Saryada

A programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, JPA, etc. If you need help on Java programming you can hire me on Fiverr.
Wayan Saryada

Leave a Reply