Quartz.Net stores all of its job related configuration in an aptly named JobStore. There are two different kinds of job stores available out of the box: RAMJobStore and AdoJobStore. By default, Quartz.Net uses a RAMJobstore. The RAMJobStore is extremely simple to configure, but it is a volatile store, so all job configuration is lost whenever the scheduler is restarted.
If you need your job configuration to be persisted between scheduler restarts and/or you are going to be running more than one instance of the scheduler in a cluster, you will need to use the AdoJobStore. This job store uses ADO.Net to persist all the job configuration information in a database. The following table shows the most common database providers that are supported, as well the name of the Quartz.Net database provider to use. The full list of providers can be found in lesson 9 of the Quartz.Net tutorial.
|Database Provider||Quartz.Net Provider Name|
|SQL Server driver for .NET Framework 2.0||SqlServer-20|
|Oracle Driver (by Microsoft)||OracleClient-20|
|MySQL Connector/:NET v. 5.1 (.NET 2.0)||MySql-51|
|SQLite ADO.NET 2.0 Provider v. 1.0.56 (.NET 2.0)||SQLite-10|
First, let’s take a look at the steps you will need to follow to start using an ADO.Net job store:
- Set up the database by creating the tables that Quartz.Net will use.
- Configure the scheduler to use the database server that you just set up.
Step 1: Setting up the databaseFirst, you will need to locate the setup script for your database server. In our case, we will use the SQL Server setup script. All setup scripts are located under the database/tables folder of the Quartz.Net distribution. The script we are looking for is called tables_sqlServer.sql. Open the script in a text editor and update the USE [enter_db_name_here] statement to point to whatever database you want to use. Once you’ve changed the database name in the script, you can go ahead and execute it. This script will create several tables in the database you set in the script. All of the Quartz.Net tables will be prefixed by QRTZ_ . Once you’ve successfully created all the tables, it’s time to configure the scheduler.
In Part 2 we will cover configuration of the scheduler.