0

In a simple jdbc example , when we load a driver through a java class, the practise is to use Class.forName("com.mysql.jdbc.Driver").newInstance(); Why we do not use new com.mysql.jdbc.Driver();?

Victor
  • 16,609
  • 71
  • 229
  • 409

1 Answers1

0

This piece of code isn't really intended to create an instance of the driver but to ensure the driver class is loaded by the class loader. Nowadays this is no longer needed, see:

Community
  • 1
  • 1
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674