I'm testing Proxool connection pool now (the DB is mysql), and I find a very curious case, which is that the mysql's Driver can always be registered to DriverManager even though I don't explicitly invoke
Class.forName("com.mysql.jdbc.Driver")
while the Proxool's Driver cann't. And I look into the JDK code and find a clue, which is that
Service.providers(java.sql.Driver.class)
can get mysql's Driver while cann't get Proxools. This maybe the reason. And my question is why this method can automatically find mysql's driver?
The following is my testing code:
public static void main(String[] args) throws Exception{
Iterator drivers = Service.providers(java.sql.Driver.class);
while(it.hasNext()){
System.out.println(it.next());
}
}
and the result is:
sun.jdbc.odbc.JdbcOdbcDriver@31d520c4
com.mysql.jdbc.Driver@1f5a3d6b