QSqlDatabase 应该使用单连接还是多连接
我有依赖类和独立类,我需要在这些类中创建数据库连接。据我了解,如果我以默认方式创建连接,所有其中使用相同的连接。
我应该为不同的类创建不同的数据库连接,还是应该使用相同的数据库连接。有什么优点和缺点? 谢谢。
I have dependent and independent classes, I need to create database connections in these classes. As I understand from Qt documentation, if I create connections in default way, all of them use same connection.
Should I create different database connections for different classes, or should I use same database connection. What are pros and cons?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定为什么 @Dummy00001 将他的回复记录为评论而不是答案,但我同意他的观点。如果您不打算以并行方式使用数据库,则不需要多个连接,事实上,它们会浪费客户端库和服务器上的资源。
I'm not sure why @Dummy00001 logged his response as a comment rather than an answer, but I concur with him. If you aren't going to be working with the database in a parallel fashion, you don't need multiple connections, and they will, in fact, be wasteful of resources both in your client library and on the server.