arnoldasgudas / Hangfire.MySqlStorage

MySql storage for Hangfire - fire-and-forget, delayed and recurring tasks runner
GNU Lesser General Public License v3.0
175 stars 113 forks source link

"You have an error in your SQL syntax" when initializing MySqlStorage #35

Open SirDerpington opened 6 years ago

SirDerpington commented 6 years ago

After downloading and installing Hangfire.MySqlStorage via the NuGet Package Manager I created an OWIN Startup class. Putting the following code in the Configuration method throws an exception.

var connectionString = 
ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString;

GlobalConfiguration.Configuration.UseStorage(new MySqlStorage(connectionString));

app.UseHangfireDashboard();

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL, ExpireAt datetime(6) DEFAULT NULL, PRIMARY KEY (Id), ' at line 10

That's the stack trace:

[MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL, ExpireAt datetime(6) DEFAULT NULL, PRIMARY KEY (Id), ' at line 10] MySql.Data.MySqlClient.MySqlStream.ReadPacket() +306 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +67 MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) +17 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +110 MySql.Data.MySqlClient.MySqlDataReader.NextResult() +772 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1513 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +118 Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:3397 Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in D:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:1346 Hangfire.MySql.MySqlObjectsInstaller.Install(MySqlConnection connection) +300 Hangfire.MySql.MySqlStorage..ctor(String nameOrConnectionString, MySqlStorageOptions options) +256 Hangfire.MySql.MySqlStorage..ctor(String nameOrConnectionString) +40 bot_framework.Startup.Configuration(IAppBuilder app) in D:\Git\bot-framework\bot-framework\Startup.cs:19

[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +160 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101 Owin.Loader.<>cDisplayClass12.bb(IAppBuilder builder) +66 Owin.Loader.<>cDisplayClass1.b0(IAppBuilder builder) +123 Microsoft.Owin.Host.SystemWeb.<>cDisplayClass2.b0(IAppBuilder builder) +71 Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) +462 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +40 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +70 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +536 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Ein Aufrufziel hat einen Ausnahmefehler verursacht.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10085804 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Is there anything I am doing wrong or some place you can point me to? It's definitely not an error caused by my code.

SirDerpington commented 6 years ago

I gave it another try with https://github.com/joel-cass/Hangfire.MySqlStorage

where (as I understand it) the only difference is that table names are prefixed with "Hangfire". It indeed seems to solve my problem.

enterpriseyes commented 4 years ago

Did anyone find solution? I am still facing this issue. I have table prefix same as it is. I am using ASp.net Core, MYSQL with Hangfire

jaxrunboo commented 1 year ago

Same problem