sql server重启后sql server连接失败

发布于 2024-09-14 04:09:59 字数 266 浏览 4 评论 0原文

我正在对我的项目进行单元测试。在一种情况下,我必须停止 sql server 并验证我的应用程序是否可以优雅地处理此类异常。

但我发现在这个测试用例运行之后,如果测试用例需要访问数据库,则在此之后运行的任何测试用例都会失败。错误是“传输级别错误”。

在每个测试用例中,我将设置一个新的 sql 连接并正常关闭它。我认为测试用例隔离得很好。我不明白为什么重新启动sql服务器会导致这样的错误。

目前,我必须在重新启动sql服务器后亲自启动它。我认为这确实是一个丑陋的修复。

i am doing a unit test against my project. in one case, i have to stop the sql server and verify if my application could handle such exception elegantly.

but i found the after this test case has run, any test case run after it would fail if the test case need to access the database. and the error was 'transportation level error'.

in each test case, i will setup a new sql connection and close it gracefully. i think the test cases are isolated very well. i do not understand why restarting the sql server would cause such error.

currently, i will have to hit the sql server myself after it is restarted. i think it is really an ugly fix.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅倚清风 2024-09-21 04:09:59

这是正常的。重新启动 SQL Server 意味着所有连接都会被终止,包括应用程序的(可能是池化的)连接。我认为你只需要处理这个错误并重试。这无疑是一种痛苦。

This is normal. Restarting the SQL Server means that all connections get killed, including your application's (possibly pooled) connection. I think you just have to handle this error and retry. Which admittedly is a pain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文