java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to check whether a driver is JDBC compliant?

package com.javacoderanch.example.sql;

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

public class JdbcCompliant {
    public static void main(String[] args) {
        try {
            String url = "jdbc:mysql://localhost/javacoderanchdb";
            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) {
        } catch (SQLException e) {