Automatic registration is a requirement for a JDBC4-compliant driver, in such cases you can skip the manual registration. A JAR file can automatically register the driver class if it contains a file
META-INF/services/java.sql.Driver
.
If your driver’s JAR file doesn’t support automatic registration, you need to find out the name of the JDBC driver classes used by your vendor.
One way is to load the driver class in your Java program. For example -
Class.forName("org.postgresql.Driver"); // force loading of driver class
This statement causes the driver class to be loaded, thereby executing a static initializer that registers the driver.
The other way is your application can set the system property
System.setProperty("jdbc.drivers", "org.postgresql.Driver");
you can also set the
jdbc.drivers
property. You can specify the property with a command-line argument
java -Djdbc.drivers=org.postgresql.Driver ProgramName