I've recently been have lots of db connection problems. The current situation is, the driver has been updated to mysql-connector-java-8.0.22.jar for linux.
The code was working and broke when I did a clean install of the OS to 20.x this caused too many problems and I reverted to 18.0.4
The class load is :
try { // The newInstance() call is a work around for some
// broken Java implementations
//Class.forName("com.mysql.jdbc.Driver").newInstance();
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
} catch (Exception ex) {
if (out != null) {
out.println("<p>Error while defining database driver: " +
"Class.forName: " + ex.getMessage());
out.println("<p>" + ex.toString() + "<p>");
// SKYPE_DEBUG.Log(DatabaseInterface.class.getName(), "mysql v[0] = "+ "\n",ex);
}
}
The actual connection code is :
query = "jdbc:mysql://localhost/bloddpressure?user=" + dbUserid + "&password=" + dbPassword;
// query = "jdbc:mysql://192.168.0.12:3307/?user=" + dbUserid + "&password=" + dbPassword;
Either of the query options give the same error.
When using:
Class.forName("com.mysql.jdbc.Driver").newInstance();
It started throwing the following error on the line
conn = DriverManager.getConnection(query);
The exception logged is:
Timestamp
Nov 12, 2020 08:38:50.273
Log Level
SEVERE
Logger
Name-Value Pairs
{levelValue=1000, timeMillis=1605170330273}
Record Number
631
Message ID
Complete Message
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
I have changed the name of the driver to :
// Class.forName("com.mysql.jdbc.Driver").newInstance();
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
But still get the same exception as above. Either call creates the same exception.