JDBC

JDBC connectivity is based on a connection URI and optional username and password. The URI is of the form:

jdbc:<driver>://<host>:<port>/<database>[?options]

Loading drivers

Since JDBC 4.0, driver classes are loaded automatically by the JVM when the driver is found on the classpath and listed in its META-INF/services/java.sql.Driver manifest.

Prior to this version it was necessary to load the driver class explicitly using Class.forName():

// MySQL
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
Class.forName("com.mysql.jdbc.Driver").newInstance();

// PostgreSQL
Class.forName("org.postgresql.Driver").newInstance();

Debugging handshake failures

Different drivers have wildly different approaches to setting up secure connectivity with the server. Start by setting some system properties to enable debugging:

java -Dlogging.level.javax=TRACE -Dlogging.level.net=TRACE -Djavax.net.debug=ssl:handshake:verbose ...