File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Need Advice on Flexible Database integration with app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need Advice on Flexible Database integration with app" Watch "Need Advice on Flexible Database integration with app" New topic

Need Advice on Flexible Database integration with app

Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45

I'm designing a software that needs a database. So, I need advice on how I can design my system so that it can adapt to any database be it MS Access or Oracle or MS SQL etc. What design patterns should I use? How about the Adapter Design pattern.


There is no patch for ignorance...
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

I think the most important things are to use a DataSource and to write code that follows the SQL spec. The DataSource will allow you to change which database you are using in one place. The standard SQL will allow the JDBC code to run on most databases.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Depending on what you are planning to do, you might also want to consider using a OR-mapping tool, such as hibernate.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

As previous poster said, if you are planning to use third party ORM tool, then you might consider Adapter pattern as well. This will help you change underlaying third party tool without modifying any thing in application.

Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
If it's a simple application, just use JDBC. No need to complicate things and bring out an ORM. And you need to look into using DAO pattern, for shielding your application from data store changes, if applicable.
I agree. Here's the link:
subject: Need Advice on Flexible Database integration with app
It's not a secret anymore!