Friday, June 19, 2009

How driver manger works internally? (in java)

DriverManager has a static registry of JDBC drivers. It has static methods registerDriver and unregisterDriver. When you load a JDBC Driver class, it calls the registerDriver method and registers itself. As many drivers can be registered to the DriverManager as you want. The order of registered drivers is significant. Because when you pass the connectionURL to the method, DriverManager.getConnection(), then it calls acceptsURL() one by one on each driver and the first driver which returns true, is used to get a connection.

No comments:

Post a Comment