DataMapperException:无法打开与“MySQL,MySQL 提供程序 5.0.8.1”的连接
我使用ibatis和net,我的数据库是mysql。
偶尔会出现以下错误,但我无法找到原因。有什么见解可能导致错误的原因吗?
iBatis 应该处理数据库连接的打开和关闭吗?然后我不确定这个错误是如何发生的。
是否可以通过编程方式关闭连接?
错误
MySql.Data.MySqlClient.MySqlException:连接太多 堆栈跟踪 [MySqlException:连接太多] 在 MySql.Data.MySqlClient.MySqlStream.OpenPacket() 在 MySql.Data.MySqlClient.NativeDriver.Authenticate411() 在 MySql.Data.MySqlClient.NativeDriver.Authenticate() 在 MySql.Data.MySqlClient.NativeDriver.Open() 在 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() 在 MySql.Data.MySqlClient.MySqlPool.GetConnection() 在 MySql.Data.MySqlClient.MySqlConnection.Open() 在 IBatisNet.DataMapper.SqlMapSession.OpenConnection(String connectionString)
[DataMapperException: 无法打开与“MySQL,MySQL 提供程序 5.0.8.1”的连接。] 在IBatisNet.DataMapper.SqlMapSession.OpenConnection(字符串连接字符串) 在 IBatisNet.DataMapper.SqlMapSession.OpenConnection() 在 IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteReader() 在IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject(RequestScope \请求,ISqlMapSession会话,对象parameterObject,对象resultObject) 在IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(ISqlMapSession\会话,对象parameterObject,对象resultObject) 在IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(ISqlMapSession\会话,对象parameterObject) 在IBatisNet.DataMapper.SqlMapper.QueryForObject(字符串语句名称,对象\参数对象) 在 F:\SVN\Edu\Persistence\SchoolRepository.cs 中的 Sun.Stream.Persistence.SchoolRepository.GetSchoolDetailsByUrl(String\ SchoolUrl):第 213 行 在 CustomExtensions.FindSchoolUrl(学校和学校) 在 EduPage.Page_PreInit(对象发送者,EventArgs e) 在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象 o,\ 对象 t,EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者,\ EventArgs e) 在 System.Web.UI.Page.OnPreInit(EventArgs e) 在 System.Web.UI.Page.PerformPreInit() 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException: 抛出了“System.Web.HttpUnhandledException”类型的异常。] 在 System.Web.UI.Page.HandleError(异常 e) 在 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,\ 布尔 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest(布尔 includeStagesBeforeAsyncPoint,\ 布尔 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest() 在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext 上下文) 在 System.Web.UI.Page.ProcessRequest(HttpContext 上下文) 在 ASP.embedplayer_aspx.ProcessRequest(HttpContext 上下文) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,Boolean&completedSynchronously)
I use ibatis with net and my DB is mysql.
This following error occurs now and then and I was unable to find the cause. Any insights what could be the cause for the errors?
iBatis should handle the opening and closing of DB connections? Then I am not sure how this error could occur.
Is it possible to programmatically close the connections?
Error
MySql.Data.MySqlClient.MySqlException: Too many connections
Stack trace
[MySqlException: Too many connections]
at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.Authenticate411()
at MySql.Data.MySqlClient.NativeDriver.Authenticate()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at IBatisNet.DataMapper.SqlMapSession.OpenConnection(String connectionString)
[DataMapperException: Unable to open connection to "MySQL, MySQL provider 5.0.8.1".]
at IBatisNet.DataMapper.SqlMapSession.OpenConnection(String connectionString)
at IBatisNet.DataMapper.SqlMapSession.OpenConnection()
at IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteReader()
at IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject(RequestScope\ request, ISqlMapSession session, Object parameterObject, Object resultObject)
at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(ISqlMapSession\ session, Object parameterObject, Object resultObject)
at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject(ISqlMapSession\ session, Object parameterObject)
at IBatisNet.DataMapper.SqlMapper.QueryForObject(String statementName, Object\ parameterObject)
at Sun.Stream.Persistence.SchoolRepository.GetSchoolDetailsByUrl(String\ SchoolUrl) in F:\SVN\Edu\Persistence\SchoolRepository.cs:line 213
at CustomExtensions.FindSchoolUrl(School& school)
at EduPage.Page_PreInit(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o,\ Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,\ EventArgs e)
at System.Web.UI.Page.OnPreInit(EventArgs e)
at System.Web.UI.Page.PerformPreInit()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.embedplayer_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需执行这个命令
just execute this command