Listing All Loaded JDBC Drivers - Java JDBC

Java examples for JDBC:Driver

Description

Listing All Loaded JDBC Drivers

Demo Code

import java.sql.Driver;
import java.sql.DriverManager;
import java.util.Collections;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    List drivers = Collections.list(DriverManager.getDrivers());
    for (int i = 0; i < drivers.size(); i++) {
      Driver driver = (Driver) drivers.get(i);

      // Get name of driver
      String name = driver.getClass().getName();

      // Get version info
      int majorVersion = driver.getMajorVersion();
      int minorVersion = driver.getMinorVersion();
      boolean isJdbcCompliant = driver.jdbcCompliant();
    }/*from w ww.j  a  va2 s  .  co m*/
  }
}

Related Tutorials