Well, it does have one side effect - it loads the driver specified by a string name into the memory.
In Java the classes are loaded only when they're actually needed to be used.
So Class.forName()
will cause the class loader to "read" the bytecode and load up the class definition into the memory of the JVM.
Now when this happens, the static initialization block of this class (and Drivers should have one) is executed (it should be static because we don't really create objects of this class).
This static initialization block written so that it registers the driver in the DriverManager.
This is a 'by the book' explanation. Of course this API is not that clear and not obvious.
Its possible to do this explicitly:
Driver driver = (Driver)Class.forName("com.mysql.jdbc.Drivercom.mysql.jdbc.Driver").newInstance();
DriverManager.registerDriver(driver);
Since Java 6 this mechanism should not be used anymore.
Read here about the new way to load up the driver.
Hope this helps