单用户数据库连接最佳实践

编程入门 行业动态 更新时间:2024-10-27 12:24:00
本文介绍了单用户数据库连接最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有了MS Access单一使用者,

这是好的做法还是可以维持一个永久的连接?

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();

解决方案<老实说,这并不重要,因为大多数数据连接是合并的,并将在你关闭后挂起来重复使用。

否则,即使使用单个用户数据库,也可以找到您的应用程序锁定

因此,请尝试:

打开连接开始事务执行工作单元提交事务 ... 开始事务执行工作单元提交事务 ... 开始事务执行工作单元提交事务 ... 关闭连接

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();

?

解决方案

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:

Open connection Start transaction Perform unit of work Commit transaction ... Start transaction Perform unit of work Commit transaction ... Start transaction Perform unit of work Commit transaction ... Close connection

更多推荐

单用户数据库连接最佳实践

本文发布于:2023-10-30 03:18:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541611.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单用户   数据库

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!