CSDN 的 z^O^时差^O^ 指出 这个应该是mysql8.0才支持,5.7的版本不行。
转自:Mars_idea 的 《不需要使用Class.forName()注册数据库的驱动也能加载到驱动》
原址:不需要使用Class.forName()注册数据库的驱动也能加载到驱动_Mars_idea的博客-CSDN博客
我们在使用jdbc操作数据库时,一般会先注册驱动,常用的方法就是使用
Class.forName("com.mysql.jdbc.Driver")
进行驱动的加载,但是最近却发现不需要使用Class.forName()注册数据库的驱动也能正常使用。一直不知道为何,网上搜了很多,发现在DriverManager类中有这样一行注释,
* <P>Applications no longer need to explicitly load JDBC drivers using <code>Class.forName()</code>. Existing programs
* which currently load JDBC drivers using <code>Class.forName()</code> will continue to work without
* modification.
所以说,不需要使用Class.forName()注册数据库的驱动也能加载到驱动。