A JDBC driver is loaded with Class.forName, which JDBC 4 does by itself
What it finds
Since JDBC 4, DriverManager finds drivers on the class path through the service loader, as its documentation says. Class.forName("org.postgresql.Driver") is left over from older versions; it ties the code to one driver class by name and fails when the driver is replaced.
Reported is Class.forName with a string literal that names a class ending in Driver.
From the rule's source, jdbc_driver_load.rs.
class Db { void load() throws Exception { Class.forName("org.postgresql.Driver");tx0 reports: JDBC 4 loads drivers by itself Class.forName("com.example.Plugin"); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:jdbc-driver-load" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:jdbc-driver-load] reason="..."tx0 explain tx0/java:jdbc-driver-load shows the same in the terminal. Found a false positive? Report it.