持久化(sql语句在官网下载过来的\database\tables文件夹下,不同数据库有不同的语句)
Quartz.NET如果不进行数据库相关配置,则默认的执行模式为内存模式,优点是执行速度快,确定就是数据无法存储,宕机了需要重新开始。
持久化只需要做如下配置(以SQLServer为例)
NameValueCollection properties = new NameValueCollection();
//存储类型
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
//表明前缀
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
//驱动类型
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
//数据源名称
properties["quartz.jobStore.dataSource"] = "myDS";
//连接字符串
properties["quartz.dataSource.myDS.connectionString"] = @"Data Source=(local);Initial Catalog=quartz;User ID=sa;Password=123";
//sqlserver版本
propert