Solr dataSource错误(Solr dataSource error)
我正在尝试使用solr进行完全导入并收到以下错误:
DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1 Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver or org.apache.solr.handler.dataimport.com.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver' 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.microsoft.sqlserver.jdbc.SQLServerDriver at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.net.FactoryURLClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)<dataConfig> <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost\ARBETSDATOR\SQLEXPRESS;integratedSecurity=true;databaseName=189021-resurs"/> <document name="members"> <entity name="member" query="SELECT * FROM Members"> <field column="MemberId" name="id"/> <field column="Name" name="name"/> </entity> </document> </dataConfig>
可能是因为不可能使用集成安全性吗?
或者连接字符串有什么问题?
更新:
下载solr时,我正在运行示例附带的码头。
我编辑了db示例以使用sql server。
我将
sqljdbc.jar
和sqljdbc4.jar
复制到\solr-4.6.0\example\example-DIH\solr\db\lib
和\solr-4.6.0\example\lib
主目录设置为
\solr-4.6.0\example\example-DIH\solr
现在这是一个新错误:
16:29:54错误DocBuilder处理时出现异常:成员文档:SolrInputDocument(fields:[]):org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document#1
16:29:54错误DataImporter完全导入失败:java.lang.RuntimeException:java.lang.RuntimeException:org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document#1
16:29:55错误DocBuilder处理时出现异常:成员文档:SolrInputDocument(fields:[]):org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM Members Processing Document#1
16:29:55错误DataImporter完全导入失败:java.lang.RuntimeException:java.lang.RuntimeException:org.apache.solr.handler.dataimport.DataImportHandlerException:无法执行查询:SELECT * FROM成员处理文档#1
我也收到有关唯一键的警告:
16:29:49 WARN IndexSchema架构中没有指定uniqueKey。
即使我已将
id
设置为uniqueKey
<fields> <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="text" indexed="true" stored="true"/> <field name="text" type="text" indexed="true" stored="false" multiValued="true"/> </fields> <!-- Field to use to determine and enforce document uniqueness. Unless this field is marked with required="false", it will be a required field --> <uniqueKey>id</uniqueKey> <!-- field for the QueryParser to use when an explicit fieldname is absent --> <defaultSearchField>text</defaultSearchField> <copyField source="id" dest="text"/> <copyField source="name" dest="text"/>
I'm trying to make a full import with solr and receiving the following error:
DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver Processing Document # 1 Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Could not load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver or org.apache.solr.handler.dataimport.com.microsoft.sqlserver.jdbc.SQLServerDriver 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.microsoft.sqlserver.jdbc.SQLServerDriver' 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.microsoft.sqlserver.jdbc.SQLServerDriver at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.net.FactoryURLClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:454)<dataConfig> <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost\ARBETSDATOR\SQLEXPRESS;integratedSecurity=true;databaseName=189021-resurs"/> <document name="members"> <entity name="member" query="SELECT * FROM Members"> <field column="MemberId" name="id"/> <field column="Name" name="name"/> </entity> </document> </dataConfig>
Could it be that it's not possible to use integrated security?
Or is there anything wrong with the connection string?
UPDATE:
I'm running the jetty that comes with the example when downloading solr.
I have edited the db example to use sql server.
I copied
sqljdbc.jar
andsqljdbc4.jar
to\solr-4.6.0\example\example-DIH\solr\db\lib
and\solr-4.6.0\example\lib
The home directory is set to
\solr-4.6.0\example\example-DIH\solr
Now it's a new error:
16:29:54 ERROR DocBuilder Exception while processing: member document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1
16:29:54 ERROR DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1
16:29:55 ERROR DocBuilder Exception while processing: member document : SolrInputDocument(fields: []):org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1
16:29:55 ERROR DataImporter Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to execute query: SELECT * FROM Members Processing Document # 1
I also get a warning about unique key:
16:29:49 WARN IndexSchema no uniqueKey specified in schema.
Even though I have set
id
touniqueKey
<fields> <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="text" indexed="true" stored="true"/> <field name="text" type="text" indexed="true" stored="false" multiValued="true"/> </fields> <!-- Field to use to determine and enforce document uniqueness. Unless this field is marked with required="false", it will be a required field --> <uniqueKey>id</uniqueKey> <!-- field for the QueryParser to use when an explicit fieldname is absent --> <defaultSearchField>text</defaultSearchField> <copyField source="id" dest="text"/> <copyField source="name" dest="text"/>
原文:https://stackoverflow.com/questions/20683831
最满意答案
尽量避免使用select语句。 还学习使用
Application.ScreenUpdating
属性来加速代码(这会禁用每次写入Excel工作表之间的屏幕刷新,并在最后更新所有内容,使其更快)Sub sumif_test() Dim ws As Worksheet Dim NoCol As Integer, NoRow As Integer Dim CritRng As Range, SumRng As Range Application.ScreenUpdating = False Set ws = Worksheets("AB") With ws NoRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row NoCol = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column Set CritRng = .Range("A:A") Set SumRng = .Range("N:N") End With For r = 2 To NoRow Cells(r, NoCol) = WorksheetFunction.SumIf(CritRng, Cells(r, 1), SumRng) Next r Application.ScreenUpdating = True End Sub
我重写了你的代码以避免使用select语句。 请看一下它,看看你是否可以弄清楚每个部分的作用。
Try to avoid using select statements. Also learn to use the
Application.ScreenUpdating
property to speed up your code (This disables the screen refreshing between each write to the excel sheet and updates everything at the end making it much faster)Sub sumif_test() Dim ws As Worksheet Dim NoCol As Integer, NoRow As Integer Dim CritRng As Range, SumRng As Range Application.ScreenUpdating = False Set ws = Worksheets("AB") With ws NoRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row NoCol = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column Set CritRng = .Range("A:A") Set SumRng = .Range("N:N") End With For r = 2 To NoRow Cells(r, NoCol) = WorksheetFunction.SumIf(CritRng, Cells(r, 1), SumRng) Next r Application.ScreenUpdating = True End Sub
I've rewritten your code to avoid using the select statement. Please take a look at it and see if you can figure out what each part does.
相关问答
更多-
Excel VBA sumif(Excel VBA sumif)[2023-02-21]
ActiveSheet.Range("AQ" & Index).Value = Sumact ActiveSheet.Range("AQ" & Index).Value = earningsDue 都看起来像他们写给这个单元格。 您确定在“L”情况下,收入到期不是空白并覆盖您的sumact值? 它看起来没有任何条件可以防止第二条线在第一条线也跑时运行。 ActiveSheet.Range("AQ" & Index).Value = Sumact ActiveSheet.Range("AQ" & Index ... -
我怀疑你只是想要这样的东西: Sub Sumif() Dim lastColumn As Long lastColumn = Cells(1, Columns.Count).End(xlToLeft).Column Cells(3, lastColumn + 1).FormulaR1C1 = "=SUMIF(R1C3:R1C" & lastColumn & ",""M"",RC3:RC" & lastColumn & ")" End Sub I suspect you just want somet ...
-
你的sumif公式是从错误的列总结:你的RC表示法相当于: =IF(COUNTIF(A$1:A1,A1)>1,"",SUMIF(A$1:A10,A1,D$1:D10)) 但你想要: =IF(COUNTIF(A$1:A1,A1)>1,"",SUMIF(A$1:A10,A1,b$1:b10)) 纠正它: .FormulaR1C1 = "=IF(COUNTIF(R1C[-4]:RC[-4],RC[-4])>1,"""",SUMIF(R1C[-4]:R[" & LastRow & "]C[-4],RC[-4],R1 ...
-
vba中的Sumif函数以及如何在公式中使用动态范围(Sumif Function in vba and how to use dynamic range in formula)[2022-10-08]
您需要将范围地址替换为公式。 未经测试: Sub xd() Const f As String = "SUMIF(Sheet1!, ,Sheet1! )" R_lastrow = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row R_lastcolumn = Sheets(1).Cells(1, Columns.Count).End(xlToLeft).Column o_lastrow = Sheets(2). ... -
Long被认为是VBA中的数据类型,因此您需要制作如下代码: Sub Example1() Dim TestVar As Long TestVar = Application.WorksheetFunction.SumIf( _ Arg1:=Sheet1.Range("B2:B11"), _ Arg2:="1", _ Arg3:=Sheet1.Range("A2:A11")) End Sub 请注意,我删除 ...
-
通过解析标准字符串我假设你的意思是多个标准? 在这种情况下,请将SUMIFS用于多个条件。 例如,做出一些假设......根据B,C和D中的标准对A1:A6中的数据求和 =SUMIFS(A1:A6,B1:B6,"<=35",C1:C6,">=12000",D1:D6,"=Male") By parse the criteria string I'm assuming you mean multiple criteria? In that case use SUMIFS for multiple crite ...
-
VBA Excel SumIf返回0(VBA Excel SumIf returns 0)[2023-09-02]
使用.Cells和.Range参考正确的工作表。 像这样的东西: With Worksheets("Name-Of-Worksheet") ValSrc = .Cells(a, 48).Value & "/DIR/" & .Cells(4, a).Value ValFnd = Application.WorksheetFunction.SumIf(.Range(.Cells(5, 309), .Cells(105673, 309)), .Range(.Cells(5, 308), .Cell ... -
VBA函数Sumif(VBA Function Sumif)[2023-05-05]
Function master(sega) master = WorksheetFunction.SumIf(sega, "<80") End Function Function master(sega) master = WorksheetFunction.SumIf(sega, "<80") End Function -
VBA sumif具有可变范围(VBA sumif with variable range)[2024-02-24]
尽量避免使用select语句。 还学习使用Application.ScreenUpdating属性来加速代码(这会禁用每次写入Excel工作表之间的屏幕刷新,并在最后更新所有内容,使其更快) Sub sumif_test() Dim ws As Worksheet Dim NoCol As Integer, NoRow As Integer Dim CritRng As Range, SumRng As Range Application.ScreenUpdating = ... -
你可能会在这之后 Dim totalHours As Double Dim dailyTotal As String: dailyTotal = "Daily Total:" Dim rng As Range: Set rng = Application.Range("Totals!E11:E100") totalHours = Application.SumIf(rng.Offset(, -1), dailyTotal, rng) Sheets("Macros").Range("C29") = tota ...