When you use a class directly, the JVM will load the class and initialize it automatically. For exaple, when you do something like
The String class is loaded and initialized. This means that memory for static variables is allocated and their values are initialized. Static initialzers are also executed. Similarly when you do
The Connection and DriverManager classes are loaded (if they aren't already loaded, that is) before the getConnection() method is even called.
However, we never use JDBC driver classes directly, so how are they loaded? By calling Class.forName()! This method will also load a class if it isn't already loaded. When the driver class is loaded, the static initializers in the class run. This is when the driver is registered with the DriverManager, as described above.
If you are interested in learning more, I suggest you look at the javadocs for Class, specifically the forName() method.
You should also look at ClassLoader.
Layne