Ubuntu 20.10 and MySQL 8.0.22: here's how to fix your code

Need help? Post your questions here.

Moderator: moderators

Ubuntu 20.10 and MySQL 8.0.22: here's how to fix your code

Postby stukafox » Tue Dec 08, 2020 6:02 pm

Hello,

You need to fix your code on the next release of Subsonic for Ubunti in order to fix a JDBC issue with MySQL:

Running the latest version of Subsonic on the latest version of Ubuntu (20.10 as of this writing) and MySQL 8.0.22 using openjdk version 1.8.0_275 results in the following error:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL ''jdbc:mysql://127.0.0.1:3306/subsonic?user=****&password=****!&characterEncoding=UTF-8''

(here's the line from /etc/default/subsonic:
SUBSONIC_ARGS="--max-memory=200 --db='jdbc:mysql://127.0.0.1:3306/subsonic?user=****&password=****!&characterEncoding=UTF-8'" )

This will happen even through the MySQL drivers are loaded, regardless of which version they are:

>lsof | grep subsonic | grep mysql*
java 48717 root mem REG 253,0 990924 8926613 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-5.1.40.jar
java 48717 root mem REG 253,0 2389215 8913841 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-8.0.22.jar
java 48717 root 78r REG 253,0 2389215 8913841 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-8.0.22.jar
java 48717 root 90r REG 253,0 990924 8926613 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-5.1.40.jar
java 48717 48718 java root mem REG 253,0 990924 8926613 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-5.1.40.jar
java 48717 48718 java root mem REG 253,0 2389215 8913841 /var/subsonic/jetty/0cfa60/webapp/WEB-INF/lib/mysql-connector-java-8.0.22.jar

(note that both jars are loaded. This error will occur no matter which jar version is loaded)

(also note: I tried both version in the pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
<scope>runtime</scope>
</dependency>
and it made no difference.)

This error is not resolvable via setting CLASSPATH or JAVA_HOME variables.

The cause of this appears to be that you're not including the correct class in your code. Please add the following line:

Class.forName("com.mysql.jdbc.Driver");

This should resolve the issue.

(incidentally, this issue is unique to Ubuntu. I tried the exact same configuration of Subsonic versions, mysql drivers, database version and jdk version on Centos and it worked perfectly)

(I like parentheses)

Thanks.
stukafox
 
Posts: 4
Joined: Mon Jun 22, 2020 7:17 pm

Re: Ubuntu 20.10 and MySQL 8.0.22: here's how to fix your co

Postby cnschulz » Mon Mar 22, 2021 4:52 am

Hi,

I think i have this same issue on 20.04. Is there a workaround?
cnschulz
 
Posts: 11
Joined: Sat Feb 04, 2012 9:09 am


Return to Help

Who is online

Users browsing this forum: Majestic-12 [Bot] and 15 guests