aspose file tools*
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

Win a copy of Java 8 in Action this week in the Java 8 forum!
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.
Don't get me started about those stupid light bulbs.
subject: Multiple Database Connection. Best practice?
Similar Threads
resource bundle
eclipse can not connect to mysql!!!
Problem with JDBC connection with MySQL
Multiple Database & Multiple Connection Problem
Multiple database & multiple connection problem.