Java DriverManager. Getdrivers() method: get all loaded drivers
•
Java
getDrivers()
Typical application
public static void main(String[] args){
try{
Class.forName("com.microsoft.sqlserver.jdbc.sqlServerDriver"); //加载数据库驱动
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=db_database01"; //定义连接数据库的url
Enumeration em = DriverManager.getDrivers(); //获取已加载JDBC驱动程序的Enumeration
while(em.hasMoreElements()){
Driver d = (Driver)em.nextElement();
System.out.println(d.getClass().getName()); //输出驱动程序类名称
}
}catch(Exception e){
e.printStackTrace();
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
