Solr DataImportHandlerException:无法执行查询

时间:2016-08-26 23:28:46

标签: search solr lucene solr4

我正在尝试通过/dataimport?command=full-import导入数据库。 solr-spec 4.8.0 我的data-config.xml:

<dataConfig>  
  <dataSource type="JdbcDataSource"
            driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
            url="jdbc:sqlserver://dbservername/dbname;instance=sqlexpress2012;"
            user="username"
            password="pwd"
            batchSize="10" 
            name="activeConnection"/>  

     <document name="Businesses">
        <entity name="Business" pk="BusinessId"                
                   query="select BusinessId from Business" >
                <field column="BusinessId" name ="id"/>
                <field column="BusinessId" name = "BusinessId"/>                    
        </entity> 
    </document> 
</dataConfig> 

日志:

    "verbose-output": [
        "entity:Business",
        [
          "document#1",
          [
            "query",
            "select BusinessId from Business",
            "EXCEPTION",
            "org.apache.solr.handler.dataimport.DataImportHandlerException: 
Unable to execute query: select BusinessId from Business Processing Document # 1\r\n\tat 
org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow(DataImportHandlerException.java:71)\r\n\tat 
org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:281)\r\n\tat 
org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:238)\r\n\tat 
org.apache.solr.handler.dataimport.JdbcDataSource.getData(JdbcDataSource.java:42)\r\n\tat 
org.apache.solr.handler.dataimport.DebugLogger$2.getData(DebugLogger.java:188)\r\n\tat 
org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)\r\n\tat 
org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)\r\n\tat 
org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:243)\r\n\tat 
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:477)\r\n\tat 
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:416)\r\n\tat 
org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:331)\r\n\tat 
org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:239)\r\n\tat 
org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:411)\r\n\tat 
org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:483)\r\n\tat 
org.apache.solr.handler.dataimport.DataImportHandler.handleRequestBody(DataImportHandler.java:179)\r\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)\r\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:1952)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:774)\r\n\tat 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:418)\r\n\tat 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)\r\n\tat 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)\r\n\tat 
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\r\n\tat 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\r\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)\r\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:368)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)\r\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)\r\n\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)\r\n\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)\r\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)\r\n\tat org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\r\n\tat java.lang.Thread.run(Unknown Source)\r\nCaused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host QBFBROKERS-DEV/CustomerConnect, port 1433 has failed. Error: \"null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.\".\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)\r\n\tat com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)\r\n\tat com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)\r\n\tat com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)\r\n\tat org.apache.solr.handler.dataimport.JdbcDataSource$1.call(JdbcDataSource.java:151)\r\n\tat org.apache.solr.handler.dataimport.JdbcDataSource$1.call(JdbcDataSource.java:131)\r\n\tat 
org.apache.solr.handler.dataimport.JdbcDataSource.getConnection(JdbcDataSource.java:394)\r\n\tat 
org.apache.solr.handler.dataimport.JdbcDataSource.access$200(JdbcDataSource.java:42)\r\n\tat org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.<init>(JdbcDataSource.java:268)\r\n\t... 43 more\r\n",
            "time-taken",
            "0:0:29.422"
          ]
        ]
      ]

我在此实例之外尝试了查询,并且我的所有数据库信息都是准确的

有关为什么dataimport无法执行我的查询的任何想法?

solr-spec 4.8.0

2 个答案:

答案 0 :(得分:0)

我认为您的网址声明中包含";",这导致了问题。

请尝试从网址声明中删除";"

应为"url="jdbc:sqlserver://dbservername/dbname;instance=sqlexpress2012"

如果这不起作用,那么

通过将instance名称更改为databaseName来确认。

然后是

url="jdbc:sqlserver://dbservername;databaseName=sqlexpress2012;"

答案 1 :(得分:0)

从异常堆栈跟踪中,您可以看到以下行:

SQLServerException:
The TCP/IP connection to the host QBFBROKERS-DEV/CustomerConnect, port 1433 has failed.
Error: \"null. Verify the connection properties.
Make sure that an instance of SQL Server is running on the host and accepting TCP/IP
connections at the port. Make sure that TCP connections to the port are not blocked
by a firewall.

您能否检查Solr实例与MS SQL实例之间的连接?特别是如果Solr实例可以访问端口1433。