英文:
Override org.apache.solr.handler.dataimport.JdbcDataSource for jdbc data direct sqlserver driver
问题
我需要重写 JdbcDataSource 类的 getConnection() 方法以解锁 Data direct 驱动器。
当 Solr 在 solr-data-config.xml 中执行存在于 Solr 核心内部的 SQL 查询时,无法执行这些 SQL 查询。
它会以错误 "this driver is locked for use with embedded applications" 失败。
我可以通过扩展 JdbcDataSource 类并重写 getConnection() 方法来解锁驱动器。
但是 Solr 并未使用我的扩展类。如何配置 Solr 以使用扩展的 JdbcDataSource。
英文:
I need to override the JdbcDataSource class getConnection() method to unlock Data direct driver.
When solr is executing the sql queries present in solr-data-config.xml inside solr cores, it is unable to execute the sql queries.
It is failing with error "this driver is locked for use with embedded applications".
I could override the getConnection() method & unlock the driver by extending the JdbcDataSource class.
But solr is not picking up my extended class. How to configure solr with extended JdbcDataSource.
答案1
得分: 1
I think the easiest way would be to create a new class that extends the old one, override getConnection()
call, include the class in a .jar-file, add the .jar-file to the libraries being loaded by Solr, then use the new name in your data source definition - dataSource type="NewAndImprovedJdbcDataSource"
.
You must the .jar file to the lib elements in solrconfig.xml
:
<lib dir="../../../<path>/" regex="my-library\.jar" />
You then reference the datasource in the data-config.xml file:
<dataSource name="<name>" type="YourCustomClass" />
英文:
I think the easiest way would be to create a new class that extends the old one, override getConnection()
call, include the class in a .jar-file, add the .jar-file to the libraries being loaded by Solr, then use the new name in your data source definition - dataSource type="NewAndImprovedJdbcDataSource"
.
You must the .jar file to the lib elements in solrconfig.xml
:
<lib dir="../../../<path>/" regex="my-library\.jar" />
You then reference the datasource in the data-config.xml file:
<dataSource name="<name>" type="YourCustomClass" />
专注分享java语言的经验与见解,让所有开发者获益!
评论