title: Solr could not load MySQL JDBC Driver
body: <p>I am using <code>Solr 4.6.1</code> on <code>Mac</code>. I try to figure out how to use data import to load data from <code>MySQL</code>. But I end up with fail to load JDBC Driver class. Here is what I did:</p>
  
  <p>Put <code>mysql-connector-java-5.1.29-bin.jar</code> to <code>~/Tools/Solr/example/lib/</code></p>
  
  <p>1.Configure <code>~/Tools/Solr/example/solr/collection1/conf/data-config.xml</code>:</p>
  
  <pre><code>&lt;dataConfig&gt;
  &lt;dataSource type="JdbcDataSource" 
            driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/test" 
            user="root" 
            password="root"/&gt;
  &lt;document&gt;
  &lt;entity name="SolrTest" 
          query="select * from SolrTest"&gt;
     &lt;field column="ID" name="id"/&gt;
     &lt;field column="Name" name="name"/&gt;
     &lt;field column="Class" name="class"/&gt;
     &lt;field column="Score" name="score"/&gt;
  &lt;/entity&gt;
  &lt;/document&gt;
  &lt;/dataConfig&gt;
  </code></pre>
  
  <p>2.Configure <code>~/Tools/Solr/example/solr/collection1/conf/solrconfig.xml</code>:</p>
  
  <p>add the following under <code>&lt; config&gt; &lt; /config&gt;</code></p>
  
  <pre><code>&lt;requestHandler name="/dataimport" 
                  class="org.apache.solr.handler.dataimport.DataImportHandler"&gt;
  &lt;lst name="defaults"&gt;
      &lt;str name="config"&gt;data-config.xml&lt;/str&gt;
  &lt;/lst&gt;
  &lt;/requestHandler&gt;
  </code></pre>
  
  <p>also</p>
  
  <pre><code>&lt;lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /&gt;
  &lt;lib dir="../../../contrib/dataimporthandler/lib" regex=".*\.jar" /&gt;
  </code></pre>
  
  <p>3.Add the following to <code>~/Tools/Solr/example/solr/collection1/conf/schema.xml</code>:</p>
  
  <pre><code>&lt;field name="id" type="int" indexed="true" stored="true" required="true"/&gt;
  &lt;field name="name" type="string" indexed="true" stored="true"/&gt;
  &lt;field name="class" type="string" indexed="true" stored="true" /&gt;
  &lt;field name="score" type="int" indexed="true" stored="true"/&gt;
  </code></pre>
  
  <p>Then run</p>
  
  <pre><code>java -jar start.jar
  </code></pre>
  
  <p>When I go to </p>
  
  <pre><code>http://localhost:8983/solr/#/collection1/dataimport//dataimport 
  </code></pre>
  
  <p>it shows</p>
  
  <pre><code>No information available (idle)
  </code></pre>
  
  <p>When I click the execute button, I got the following error message:</p>
  
  <blockquote>
    <p>31537 [Thread-15] ERROR org.apache.solr.handler.dataimport.DataImporter  – 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    at
    org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:270)
      at
    org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)
      at
    org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:476)
      at
    org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:457)
    Caused by: java.lang.RuntimeException:
    org.apache.solr.handler.dataimport.DataImportHandlerException: Could
    not load driver: com.mysql.jdbc.Driver Processing Document # 1    at
    org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:410)
      at
    org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:323)
      at
    org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:231)
      ... 3 more Caused by:
    org.apache.solr.handler.dataimport.DataImportHandlerException: Could
    not load driver: com.mysql.jdbc.Driver Processing Document # 1    at
    org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)
      at
    org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:116)
      at
    org.apache.solr.handler.dataimport.JdbcDataSource.init(JdbcDataSource.java:64)
      at
    org.apache.solr.handler.dataimport.DataImporter.getDataSourceInstance(DataImporter.java:383)
      at
    org.apache.solr.handler.dataimport.ContextImpl.getDataSource(ContextImpl.java:99)
      at
    org.apache.solr.handler.dataimport.SqlEntityProcessor.init(SqlEntityProcessor.java:53)
      at
    org.apache.solr.handler.dataimport.EntityProcessorWrapper.init(EntityProcessorWrapper.java:74)
      at
    org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:427)
      at
    org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:408)
      ... 5 more Caused by: java.lang.ClassNotFoundException: Unable to
    load com.mysql.jdbc.Driver or
    org.apache.solr.handler.dataimport.com.mysql.jdbc.Driver  at
    org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:916)
      at
    org.apache.solr.handler.dataimport.JdbcDataSource.createConnectionFactory(JdbcDataSource.java:114)
      ... 12 more Caused by: org.apache.solr.common.SolrException: Error
    loading class 'com.mysql.jdbc.Driver'     at
    org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:470)
      at
    org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:401)
      at
    org.apache.solr.handler.dataimport.DocBuilder.loadClass(DocBuilder.java:906)
      ... 13 more Caused by: java.lang.ClassNotFoundException:
    com.mysql.jdbc.Driver     at
    java.net.URLClassLoader$1.run(URLClassLoader.java:366)    at
    java.net.URLClassLoader$1.run(URLClassLoader.java:355)    at
    java.security.AccessController.doPrivileged(Native Method)    at
    java.net.URLClassLoader.findClass(URLClassLoader.java:354)    at
    java.lang.ClassLoader.loadClass(ClassLoader.java:423)     at
    java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:789)     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:356)     at
    java.lang.Class.forName0(Native Method)   at
    java.lang.Class.forName(Class.java:264)   at
    org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)
      ... 15 more</p>
  </blockquote>
  
  <p>How to solve this?</p>