Class.forName("com.mysql.jdbc.Driver");
This will dynamically load the given class name; if else exists, it will throw a ClassNotFoundException .
Class.forName("com.mysql.jdbc.Driver").newInstance();
In addition to this, it will be done above, a new object / instance of the given class name will also be created.
In jdbc, the first is enough, since we only need to register the jdbc driver, there is no need to explicitly create a new object / instance.
You can also manually load jdbc drivers using command line options.
java -Djdbc.drivers=com.mysql.jdbc.Driver MyApp
source share