File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Multiple Database Connection. Best practice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Multiple Database Connection. Best practice?" Watch "Multiple Database Connection. Best practice?" New topic

Multiple Database Connection. Best practice?

Lorenzo Tagliaferro

Joined: Jun 15, 2009
Posts: 20

Hi everyone!!

I'm trying to create a simple stand-alone project (no web-app), where there are 2 kinds of Database (MySQL, Postgres).

I would like to know, what is the best practice to create a class or a method that store the drives and istantiate the connection with differente databases.

This is, what I have created:

Thank in advance!!
Hongli Li
Ranch Hand

Joined: Oct 29, 2006
Posts: 124
you can create two property files one for mysql and the other for postgres, so you can selectively load the properties by a flag. I would use spring to manage database access.

Do you know why this cup is useful? Because it is empty.
I agree. Here's the link:
subject: Multiple Database Connection. Best practice?
Similar Threads
resource bundle
Problem with JDBC connection with MySQL
Multiple database & multiple connection problem.
Multiple Database & Multiple Connection Problem
eclipse can not connect to mysql!!!