在NHibernate中自动重试失败的连接 [英] Automatic retry of failed connection in NHibernate

查看:73
本文介绍了在NHibernate中自动重试失败的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让NHibernate自动重试与数据库的失败连接?具体来说,如果我的网络连接太不可靠,有时NH将无法连接到我的远程SQL Server.

Is there a way to ask NHibernate to automatically retry failed connections to a database? Specifically, if my network connection is too unreliable, sometimes NH will fail to connect to my remote SQL Server.

推荐答案

可能(只是一个主意)可以通过重写连接驱动程序的GenerateCommand()方法来重试.在那里,您将返回包装好的IDbCommand,该IDbCommand将在必要时重试.

You might (just an idea) be able to get retries by overriding the connection driver's GenerateCommand() method. There you would return a wrapped IDbCommand that retries as necessary.

如果您使用的是偶尔连接"的要求,请参阅此问题.

If you are working with "occasionally connected" requirements, see this question.

这篇关于在NHibernate中自动重试失败的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆