1

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?

6
  • 1
    The usual way is with an ORM, or with DAO objects. See also Domain-Driven Design.CommentedApr 6, 2015 at 15:24
  • recommended reading: Green fields, blue skys, and the white board - what is too broad?
    – gnat
    CommentedApr 6, 2015 at 15:25
  • @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.CommentedApr 6, 2015 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.CommentedApr 6, 2015 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.CommentedApr 6, 2015 at 15:33

1 Answer 1

4

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.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.