AdoJobStore与Sqlite

时间:2014-10-21 13:28:59

标签: c# sqlite quartz.net

我终于能够为Sql Server设置ADOJobStore,但我还希望它可以与 Sqlite 一起使用,而我仍然无法使用它。这是我为quartz.config设置属性AdoJobStore的一部分:

# to use the sqlite store, uncomment all of this 
quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz 
quartz.jobStore.dataSource = default 
quartz.dataSource.default.connectionString = Data Source=postbag-jobs.db;Version=3;Foreign Keys=ON;
quartz.jobStore.tablePrefix = QRTZ_ 
quartz.jobStore.clustered = false
quartz.jobStore.lockHandler.type = Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz 
quartz.jobStore.driverDelegateType = Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz 
quartz.dataSource.default.provider = SQLite-10 
quartz.jobStore.useProperties = true

我已经单独创建了Sqlite数据库并将其放在我服务器的工作目录中。但是,当服务初始化时,我得到一个SchedulerException,上面写着:

Could not Initialize DataSource: default

使用此InnerException

Error while reading metadata information for provider 'SQLite-10'
Parameter name: providerName

我是否必须为我的服务器提供Sqlite .DLL?因为我不需要为Sql Server做到这一点。

1 个答案:

答案 0 :(得分:8)

如果您想将 Sqlite Quartz.net 一起使用,则必须使用以下密钥:

<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.jobStore.useProperties" value="true" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.tablePrefix" value="qrtz_" />
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SQLiteDelegate, Quartz" />
<add key="quartz.dataSource.default.provider" value="SQLite-10" />
<add key="quartz.dataSource.default.connectionString" value="Data Source=postbag-jobs.db;Version=3;" />

我注意到您的 driverDelegateType 键不正确。您应该使用 SQLiteDelegate

<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SQLiteDelegate, Quartz" />

您还需要安装ADO.NET provider nuget ):

Install-Package System.Data.SQLite.Core

您可能遇到的另一个问题是与您的提供商( 1.0.94.0 )的兼容性以及Quartz.Net( 1.0.88.0 )中定义的兼容性。您可以找到信息here

要解决此问题,只需将此部分添加到 app.config

即可
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
            <bindingRedirect oldVersion="1.0.88.0" newVersion="1.0.94.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

可以在github上找到一个工作示例here