Class.forName() doesn't do anything like that, it just loads the mentioned class.
Some JDBC drivers register themselves when their static { ... } class initialization
code is invoked; other JDBC drivers don't do that and you have to register such
driver yourself. Note that both these variants are outdated (see the API docs).
kind regards,
Jos
Of course Class.forName when called simply loads the mentioned class, but when called on a driver class the static initializer of that class would then perform the other actions I was talking about. So in the context of drivers and when comparing Class.forName with DriverManager.registerDriver .... ugh, I'm just trying to defend myself here ....
From
this page they have :
"All Driver classes should be written with a static section (a static initializer) that creates an instance of the class and then registers it with the DriverManager class when it is loaded.
....
A Driver class is loaded, and therefore automatically registered with the DriverManager, in one of two ways:
- by calling the method Class.forName. This explicitly loads the driver class. Since it does not depend on any external setup, this way of loading a driver is the recommended one for using the DriverManager framework. The following code loads the class acme.db.Driver:
Class.forName("acme.db.Driver");
If acme.db.Driver has been written so that loading it causes an instance to be created and also calls DriverManager.registerDriver with that instance as the parameter (as it should do), then it is in the DriverManager's list of drivers and available for creating a connection.
.....
"