A JDBC driver is loaded with Class.forName, which JDBC 4 does by itself

tx0/java:jdbc-driver-loadrecommendedwarningsmell

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.

Example from the rule's tests
class Db {  void load() throws Exception {    Class.forName("org.postgresql.Driver");tx0 reports: JDBC 4 loads drivers by itself    Class.forName("com.example.Plugin");  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

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.