title: calling stored procedure from solr
body: <p>I’m writing an application that searches by solr 3.4. To fill the index of solr I use the dataimporthandler and the com.microsoft.sqlserver.jdbc.SQLServerDriver class to get the data from the MS SQL database.</p>
  
  <p>Now I’m trying to call a stored procedure on Database but solr log always return errors:</p>
  
  <pre><code>Full Import failed:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: exec dbo.h_getThumbnails @h = '52'        Processing Document # 48
      at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72)
      at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.&lt;init&gt;(JdbcDataSource.java:253)
      at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:210)
      at org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:39)
      at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
      at org.apache.solr.handler.dataimport.CachedSqlEntityProcessor.getAllNonCachedRows(CachedSqlEntityProcessor.java:69)
      at org.apache.solr.handler.dataimport.EntityProcessorBase.getSimpleCacheData(EntityProcessorBase.java:259)
      at org.apache.solr.handler.dataimport.CachedSqlEntityProcessor.nextRow(CachedSqlEntityProcessor.java:58)
      at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:238)
      at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:596)
      at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:622)
      at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:268)
      at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:187)
      at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:359)
      at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:427)
      at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:408)
  Caused by: java.lang.NullPointerException
      at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.&lt;init&gt;(JdbcDataSource.java:251)
      ... 14 more
  </code></pre>
  
  <p>The I’ve tried diferent versions to call the stored procedure. Here the queries:</p>
  
  <pre><code>&lt;entity  name="PicturePath" processor="CachedSqlEntityProcessor" query="exec dbo.h_getThumbnails @h = 4
  "&gt;      &lt;/entity&gt;
  
  &lt;entity  name="PicturePath" processor="CachedSqlEntityProcessor" query="call dbo.h_getThumbnails @h = 4
  "&gt;      &lt;/entity&gt;
  &lt;entity  name="PicturePath" processor="CachedSqlEntityProcessor" query=" dbo.h_getThumbnails @h = 4
  "&gt;      &lt;/entity&gt;
  </code></pre>
  
  <p>Does anyone know how to call a stored procedure from solr? Or does anyone know where I should search the cause?</p>
  
  <p>Thanks a lot for all your answers!</p>