• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do we use multiple database connections?

 
Shahir Deo
Ranch Hand
Posts: 80
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we use multiple database connections? What is the primary use of this?
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

If your application wants to work with two (or more) databases, it will have to use multiple connections.

Another reason might be to run several operations in parallel (for example, handle several user requests in a web application). A connection pool is often used in this scenario.

Are these the cases you wanted to discuss, or is there something else you had on your mind?
 
Rob Spoor
Sheriff
Posts: 20829
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compare a database connection to a cash register in a super market. If there is only one, everybody has to line up at that one single cash register to pay for their shopping. Imagine how long this line could become if there are several dozens of people wanting to pay.

So just like there often are multiple cash registers to help multiple people at once (thereby splitting the single long line into multiple shorter ones), multiple database connections allow more requests to be handled at once. In any web application this is really a must, otherwise your website could only service one user at a time.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!