It does not depend on the Java version, but on JDBC. In JDBC 4.0, autoloading of the DBMS driver via the Service Provider (SPM) mechanism appeared.
When you request a connection, DriverManager
scans the classpath via the ServiceLoader and searches for META-INF/services/java.sql.Driver
DriverManager
files, and then loads all the classes listed in them. For example, the contents of this file in the MySQL driver:
META-INF / services / java.sql.Driver
com.mysql.jdbc.Driver com.mysql.fabric.jdbc.FabricMySQLDriver
In order not to rely on SPM support for a specific driver, you can register it manually through Class.forName()
.
The MySQL 3.xx driver version does not support SPM, i.e. driver must be loaded manually.