我试图搜索我的具体问题,但没有找到解决方案。我还在DIH上阅读了wiki,似乎一切设置正确,但我的查询仍然失败。谢谢你的帮助
我正在使用Tomcat 6.0运行Solr 3.1 Windows server 2003 r2和SQL 2008
我的sqljdbc4.jar位于C:\ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ lib
我的solrconfig.xml
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
我的db-data-config.xml
<dataConfig>
<dataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="://localhost:1433;DatabaseName=KnowledgeBase_DM" user="user" password="password" />
<document>
<entity name="Titles" query="SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data">
<field column="mrID" name="id" />
<field column="mrTitle" name="title" />
<entity name="Desc" query="select meDescription from KnowledgeBase_DM.dbo.AskMe_Data">
<field column="meDescription" name="description" />
</entity>
</entity>
</document>
</dataConfig>
日志内容:
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImportHandler processConfiguration
INFO: Processing configuration from solrconfig.xml: {config=db-data-config.xml}
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImporter loadDataConfig
INFO: Data Configuration loaded successfully
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.DataImporter doFullImport
INFO: Starting Full Import
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.SolrWriter readIndexerProperties
**WARNING: Unable to read: dataimport.properties**
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call
INFO: Creating a connection for entity Titles with URL: ://localhost:1433;DatabaseName=KnowledgeBase_DM
Jan 25, 2012 2:17:37 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call
INFO: Time taken for getConnection(): 0
Jan 25, 2012 2:17:37 PM org.apache.solr.common.SolrException log
**SEVERE: Exception while processing: Titles document : SolrInputDocument[{}]:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data Processing Document # 1**
at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(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.DebugLogger$2.getData(DebugLogger.java:188)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:238)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:591)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:267)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:186)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:353)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:411)
at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:205)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:241)
... 28 more
Jan 25, 2012 2:17:37 PM org.apache.solr.common.SolrException log
**SEVERE: Full Import failed:org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT mrID, mrTitle from KnowledgeBase_DM.dbo.AskMe_Data Processing Document # 1**
at org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:72)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(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.DebugLogger$2.getData(DebugLogger.java:188)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:238)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:591)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:267)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:186)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:353)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:411)
at org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:205)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1360)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:241)
... 28 more
Jan 25, 2012 2:17:37 PM org.apache.solr.update.DirectUpdateHandler2 rollback
INFO: start rollback
Jan 25, 2012 2:17:37 PM org.apache.solr.update.DirectUpdateHandler2 rollback
INFO: end_rollback
Jan 25, 2012 2:17:37 PM org.apache.solr.core.SolrCore execute
INFO: [] webapp=/solr path=/select params={start=0&dataConfig=<dataConfig>%0d%0a%09<dataSource+driver%3D"com.microsoft.sqlserver.jdbc.SQLServerDriver"+url%3D"://localhost:1433;DatabaseName%3DKnowledgeBase_DM"+user%3D"user"+password%3D"password"+/>%0d%0a%09<document>%0d%0a%09%09<entity+dataSource%3D"ds1"+name%3D"Titles"+query%3D"SELECT+mrID,+mrTitle+from+KnowledgeBase_DM.dbo.AskMe_Data">%0d%0a%09%09%09<field+column%3D"mrID"+name%3D"id"+/>%0d%0a%09%09%09<field+column%3D"mrTitle"+name%3D"title"+/>%0d%0a%09%09%09<entity+name%3D"Desc"+query%3D"select+meDescription+from+KnowledgeBase_DM.dbo.AskMe_Data">%0d%0a%09%09%09%09<field+column%3D"meDescription"+name%3D"description"+/>%0d%0a%09%09%09</entity>%0d%0a%09%09</entity>%0d%0a%09</document>%0d%0a</dataConfig>&verbose=on&command=full-import&debug=on&qt=/dataimport&rows=10} status=0 QTime=10
答案 0 :(得分:1)
您似乎忘了描述要用于连接数据库的协议。 对于MSSQL,它是
url="jdbc:sqlserver://localhost:1433;DatabaseName=KnowledgeBase_DM"
我很确定您不需要在查询中重新显示tue数据库名称,因为您已在您的URL中选择了它。 Wich将查询发送到:
query="SELECT mrID, mrTitle from dbo.AskMe_Data"
我从来没有使用MSSQL,所以我不知道你是否应该使用dbo.AskMe_Data或只是,就像我总是使用它一样,AskMe_Data
我认为此代码应该可以解决问题:
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;DatabaseName=KnowledgeBase_DM" user="user" password="password" />
<document>
<entity name="Titles" query="SELECT mrID, mrTitle from dbo.AskMe_Data">
<field column="mrID" name="id" />
<field column="mrTitle" name="title" />
<entity name="Desc" query="select meDescription from dbo.AskMe_Data">
<field column="meDescription" name="description" />
</entity>
</entity>
</document>
</dataConfig>
答案 1 :(得分:-1)
sqljdbc4.jar应放在另一个目录
中如果这是您配置文件的地方
C:\Program Files\Apache Software Foundation\Tomcat 6.0\solr\conf\solrconfig.xml
然后sqljdbc4.jar应该放在这里:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\solr\lib\sqljdbc4.jar