单用户数据库连接最佳实践
对于 MS Access 单用户,
自始至终保持持久连接是好习惯还是可以?
伪代码:
app.start();
access.connect();
domanymanystuff();
access.disconnect();
app.exit();
--- 或 ----
app.start();
access.connect();
doonetask();
access.disconnect();
...
access.connect();
doanothertask();
access.disconnect();
...
app.exit();
?
With MS Access single user,
Is it good practice or okay to maintain a persistent connection throughout?
psuedocode:
app.start();
access.connect();
domanymanystuff();
access.disconnect();
app.exit();
--- OR ----
app.start();
access.connect();
doonetask();
access.disconnect();
...
access.connect();
doanothertask();
access.disconnect();
...
app.exit();
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
老实说,这并不重要,因为大多数数据连接都是池化的,并且在关闭它们后会保留以供重用。您确实希望确保您的事务以“每个工作单元”的方式执行。
否则,即使使用单个用户数据库,您也可能会发现应用程序将自身锁定。
所以,试试这个:
Honestly it won't matter since most data connection are pooled and will hang around for reuse after you have closed them. You do want to make sure that your transactions are performed in a 'per unit of work' fashion.
Otherwise, even with a single user DB you could find your application locking itself out.
So, try this:
您可以在整个过程中与单用户数据库保持持久连接。
You can maintain a persistent connection throughout with a single-user database.