File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Why do we use multiple database connections? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why do we use multiple database connections?" Watch "Why do we use multiple database connections?" New topic
Author

Why do we use multiple database connections?

Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 78

Why do we use multiple database connections? What is the primary use of this?


Knowledge enlivens the soul.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

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

Joined: Oct 27, 2005
Posts: 19651
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: Why do we use multiple database connections?
 
Similar Threads
What is the real use of interface in java apart from Multiple inheritance,
Reader class
JBOSS keeps creating the UDP socket connections without closing it
Java Database connection
JMS - Transaction processsing