aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes changing databases efficiently Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "changing databases efficiently" Watch "changing databases efficiently" New topic
Author

changing databases efficiently

David Pantale
Ranch Hand

Joined: Mar 16, 2010
Posts: 32

Does anyone have a good suggestion on how to set up the code to efficiently change from the project database to a commercial database? Right now I have a business services layer that has a data layer object reference and simply calls the data layer methods and passes in the data. For example: datalayer.updateData(recordNum, lockCookie);

This works, but I'm sure there must be a better way to setup the application to switch from the homegrown db to a commercial app. Any suggestions?

Thanks

Dave
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5521
    
  13

I have trouble with understanding what your asking.

Now your application works with a flat database file. You have an interface and 1 implementation. If the company decides to use a rdbms (like mysql) instead of the flat database file, you have to implement the given interface a second time. The current implementation (Data class) will be replaced with this new implementation and the application will still keep working.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
David Pantale
Ranch Hand

Joined: Mar 16, 2010
Posts: 32
Sorry about that, I phrased the post poorly. I guess I'm just curious about how other people handled the problem of setting up their application to deal with the issues of using different databases. I know someone (you?) did a dao factory pattern.

Dave
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5521
    
  13

David Pantale wrote:I know someone (you?) did a dao factory pattern.

Yes, that was me I stuck very close to the instructions and developed only the "must" requirements, except this dao factory pattern. In my opinion it really has a lot of added value, it gives you tons of flexibility. You can simply extend your application with another DAO (one for customers for example), when you have different DAOs you can easily stick to the one for flat database file for customers and already start using a MySql-based one for bookings,...
David Pantale
Ranch Hand

Joined: Mar 16, 2010
Posts: 32
Could you explain in a little more detail how you did it? I'm thinking maybe I should do the same.

Thanks
Dave
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5521
    
  13

There is nothing much I can tell about it. I just added the dao factory pattern and I use this factory to retrieve the appropriate instance of my dao (data class). So the only public api from the db-package are the interfaces and this factory. So classes from other packages don't know about the existence of the Data class.

I believe I used this link as one of my resources (it has been a long time ago )
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: changing databases efficiently