Adam
Adam

Reputation: 6192

Apache Solr/JDBC/MySQL.Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server

My Solr 8.10.1 data-importhandler indexer is throwing error when trying to import from MySQL5.7.

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.get(Object)" because "this.serverVariables" is null

I was alarmed by the occurence of jdbc4 in there.

My environment variables: JAVA_HOME: C:\Program Files\Java\jdk-17.0.1 PATH: C:\Program Files\Java\jdk-17.0.1\bin;C:\Program Files (x86)\Java\jre1.8.0_311\bin

I have jdbc9 in my solr folder: \solr-8.10.1\dist\mssql-jdbc-9.4.0.jre8.jar

So I searched my entire drive for jdbc and found just 1 occurrence of jdbc4 in D:\solr431_DELETEME\example\lib\sqljdbc4.jar, which I've also deleted, but the error above keeps occurring.

data-config.xml

<dataSource type="JdbcDataSource" name="ds-wordpress" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/wpmydb" user="<myuser>" password="<mypwd>" />

My configuration does work on my local machine, so it MUST be a setting on the server, I just don't know what it is.

I already checked here: MySQLNonTransientConnectionException Could not create connection to database server. Caused by: java.lang.NullPointerException

And tried this URL too, but to no avail: url="jdbc:mysql://localhost:3306/wpmydb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT"

What else can I try?

Upvotes: 0

Views: 808

Answers (1)

Dimanshu Parihar
Dimanshu Parihar

Reputation: 377

First : Check if you have JDBC driver available in your solr. If not you can download and copy in dist folder or lib folder in solr and map that path in solrconfig.xml file.

Second : If you are sure the first step is not an issue in your case then try to uninstall different versions of java you have and install a single version for your JDK and JRE.

Third : If first and second both not working, then it might be the issue with your username password or maybe you are using VPN to access your server which you forget to use this time.

Upvotes: 0

Related Questions