Sign in to follow this  

[java] Proper usage of databases?

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a project which requires regular database usage, I'm using the DB4O database engine but I'm not having to get too involved with it, just storage of fairly simple objects. However this is my first time really using databases and I was wondering what is the best method for interacting with my database? So far I've come up with two options: either create a database handler class, or have each class handle its own db interaction. I'm not the best at explaining things so I'll try to show an example of what I mean. Say for example I'm trying to store cars in a database, so I have a class called Car. I could have another class called DatabaseIO which has methods such as addCar(), deleteCar(), findCar() etc, or I could have static methods within the Car class to do this. I've been swaying between the two options, I think having a DatabaseIO class would probably be better, it keeps everything separate and seems a more OO way of doing things, but then again I'm pretty new to OO design. Cheers for the advice, sorry for the waffle!

Share this post


Link to post
Share on other sites

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this