guryanovev / CrystalQuartz

pluggable UI for Quartz.NET
MIT License
1.01k stars 313 forks source link

When using MySQL as a data source I get an exception trying to cast DBNull to null #100

Open maxinfet opened 1 year ago

maxinfet commented 1 year ago

When I set quartz.dataSource.defaultSql.provider to MySql I get the following exception

One or more errors occurred. (Couldn't obtain triggers for job: Object cannot be cast from DBNull to other types.)
Couldn't obtain triggers for job: Object cannot be cast from DBNull to other types.
Object cannot be cast from DBNull to other types.

and here is the stack trace

This exception was originally thrown at this call stack:
    System.DBNull.System.IConvertible.ToInt32(System.IFormatProvider) in DBNull.cs
    Quartz.Impl.AdoJobStore.SimpleTriggerPersistenceDelegate.ReadTriggerPropertyBundle(System.Data.Common.DbDataReader) in SimpleTriggerPersistenceDelegate.cs
    Quartz.Impl.AdoJobStore.StdAdoDelegate.SelectTrigger(Quartz.Impl.AdoJobStore.ConnectionAndTransactionHolder, Quartz.TriggerKey, System.Threading.CancellationToken)

These are the settings I used and I pulled these from our configuration file for our service and can use them from another client we wrote for writing jobs to the database

NameValueCollection properties = new()
{
   ["quartz.threadPool.type"] = "Quartz.Simpl.DefaultThreadPool, Quartz",
   ["quartz.threadPool.threadCount"] = "10",
   ["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
   ["quartz.jobStore.dataSource"] = "defaultSql",
   ["quartz.jobStore.tablePrefix"] = "qrtz_",
   ["quartz.jobStore.clustered"] = "true",
   ["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz",
   ["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.MySQLDelegate, Quartz",
   ["quartz.dataSource.defaultSql.provider"] = "MySql",
   ["quartz.dataSource.defaultSql.connectionString"] = "Server=server;Database=database;User=username;Pwd=password;Pooling=true;MinimumPoolSize=0;MaximumPoolSize=1000;ConnectionLifetime=0;ConvertZeroDateTime=true;SslMode=None", 
   ["quartz.jobStore.useProperties"] = "false",
   ["quartz.serializer.type"] = "binary"
};