Search code examples
javaclassloaderjdbc

What purpose does Class.forName() serve if you don't use the return value?


I've seen this line in a sample application for using a commercial JDBC driver:

Class.forName("name.of.a.jcdb.driver")

The return value is not used.

What purpose does this line serve?


Solution

  • It performs a static loading of that class. So anything in the static { } block, will run.