Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I've just finished a book on MySQL and I'm in the infantile stages of learning to couple that with Java. I know that the technology I need to learn is called JDBC and that it essentially allows you to execute programmatically created SQL statements. I plan on making a database centered records keeping and management program as a long term project. I'm not quite sure how to fit in a program structure to interact with the database.

Why is the typical way this is done, in terms of high level organization?

How do I go about organizing classes to put together SQL statements and work with them and trade info back and forth with the program and handle results?

What are some do's and more importantly, what are some don'ts?

share|improve this question

closed as too broad by gnat, durron597, Snowman, Bart van Ingen Schenau, MichaelT Apr 6 at 16:48

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

1  
The usual way is with an ORM, or with DAO objects. See also Domain-Driven Design. –  Robert Harvey Apr 6 at 15:24
    
    
@gnat While I feel that this question is on the borderline, I'd argue that because I gave a specific intended usage, I think that answers can be created. For example, I suspect some typical design patters exists, such as something like MVC for database interaction. I suspect there are thinks like common pitfalls that new programmers encounter as well. –  HCBPshenanigans Apr 6 at 15:27
1  
I already gave you two design patterns: ORM and DAO. MVC is primarily a UI pattern; it generally uses ORM in the Model. –  Robert Harvey Apr 6 at 15:29
    
@RoberHarvey I saw, and I will have to read about them. I was not suggesting that MVC was an appropriate pattern here. I'm just saying that I suspected some widely know patter probably exists for what I want. It is extremely hard to google something when you don't even know what you are looking for. It's like trying to google an instrumental song. The only real way to find what you need is to either listen to every song ever, or find someone who knows. –  HCBPshenanigans Apr 6 at 15:33

1 Answer 1

A typical "MVC for the web" program might look something like this:

RDBMS <--> ORM <--> DAL/SL <--> Controller <--> ViewModel <--> View

RDBMS - Your database, usually something like SQL Server, Oracle or Postgresql.

ORM - An Object-Relational Mapper, like Hibernate. The ORM converts tables to class objects, and vice versa.

DAL/SL - Data Access layer/Service Layer/Repository. This is a layer of abstraction between your DAL and your User Interface that provides data retrieval services, business logic, and so forth.

ViewModel - The View Model maps data between your domain objects and a user interface. It can also contain user-interface logic.

View - The User Interface.

That ought to keep you busy for awhile.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.