2

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.

1
  • 4
    Not a Qt/MySQL specialist, but in general. Multiple connections == multiple sessions == multiple outstanding transactions in the DB (plus whatever resource overhead that has). If you do not need multiple parallel transactions, then you do not need multiple connections. Commented Sep 15, 2010 at 12:06

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.