Java – Solr cannot load MySQL JDBC Driver
I use Solr 4.6 on Mac 1. I try to find out how to load data from MySQL using data import But I couldn't load the jdbc driver class in the end This is what I do:
Mysql-connector-java-5.1 29-bin. Jar ~ / tools / Solr / example / Lib/
1. Configure ~ / tools / Solr / example / Solr / Collection1 / conf / data config xml:
<dataConfig> <dataSource type="JdbcDataSource" driver="com.MysqL.jdbc.Driver" url="jdbc:MysqL://localhost:3306/test" user="root" password="root"/> <document> <entity name="SolrTest" query="select * from SolrTest"> <field column="ID" name="id"/> <field column="Name" name="name"/> <field column="Class" name="class"/> <field column="score" name="score"/> </entity> </document> </dataConfig>
2.Configure~ / Tools / Solr / example / solr / collection1 / conf / solrconfig. xml:
Add the following under configuration > < / configuration >
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.dataimporthandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
also
<lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /> <lib dir="../../../contrib/dataimporthandler/lib" regex=".*\.jar" />
3. Add the following content to ~ / tools / Solr / example / Solr / Collection1 / conf / schema xml:
<field name="id" type="int" indexed="true" stored="true" required="true"/> <field name="name" type="string" indexed="true" stored="true"/> <field name="class" type="string" indexed="true" stored="true" /> <field name="score" type="int" indexed="true" stored="true"/>
Then run
java -jar start.jar
When I go
http://localhost:8983/solr/#/collection1/dataimport//dataimport
indicate
No information available (idle)
When I click the execute button, I receive the following error message:
How to solve this?
Solution
>Create a folder in the Solr installation directory (e.g. solr-4.6.1 / LIB)
< lib dir = ".. /.. /.. / lib /" regex = "mysql-connector-java-5.1.29-bin.jar" / > > Restart Solr
Please also check your website It has//
http://localhost:8983/solr/#/collection1/dataimport//dataimport