Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxinfet opened this issue Feb 24, 2023 · 0 comments

Comments

@maxinfet
Copy link

maxinfet commented Feb 24, 2023

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"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant