Could not load driver: com.mysql.jdbc.Driver Processing Document
When import data from MySQL and index into Solr 6, the added documents always display 0. When checking the logging in Solr control panel, get this error:
Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.mysql.jdbc.Driver Processing Document # 1
The reason: to use MySQL data import handler, the JVM must contains MySQL JDBC driver jar, which is not part of JVM, and also not shipped with Solr. If we are using some kind of build tool like Maven or Gradle like the most cases, we should not worry about this issue, the tool will handle it for us. With various build automation tool in Java world, we rarely need to find and download jar file and care about the classpath problem. There are some exceptions, like this case. We need to make sure MySQL jar in the classpath by ourself.
Solution: copy the MySQL JDBC driver to server/lib directory of Solr.
I found a driver in my Gradle cache directory so I just copy the file as below.
Now the import is successful
Solr
Solr Basics
Solr Configuration
Overview
solrconfig.xml
solr.xml
schema.xml