0

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
jason
  • 364
  • 1
  • 3
  • 10
  • possible duplicate of [How is driver class located in JDBC4](http://stackoverflow.com/questions/18288058/how-is-driver-class-located-in-jdbc4) – Mark Rotteveel Apr 17 '14 at 11:02
  • Proxool is either not JDBC 4 compliant, or explicitly chose not to declare itself in `META-INF/services/java.sql.Driver` – Mark Rotteveel Apr 17 '14 at 11:05

0 Answers0