Good day, my situation is the follow: I am designing a small web system using java, my knowledge in this field is very limited (and principally comes from small tutorials and Head and First Servlets and JSP Book) with produces as result and endless flow of doubts about how to make a good (and efficient) design, the only thing that is 100% clear is that MVC is a must (at least in my case).
After reading this this I got a general idea of how the system should be done. How to implement the view and the controller (and how they shall communicate) became clear.
Now, my problem resides in the model part of the MVC pattern. Java Beans and DAO classes are to be used here right? My application will have mainly CRUD operations (only 2 - 3 additional data operations will be needed in the whole system) so, am I supposed to do N (being N the number of tables with I need access to) Java Bean objects and N DAO classes with only those CRUD operations with the follow structure?
Java Bean:
public class TableJB{
// Table attributes with their respective getters and setters
}
DAO:
public class TableJB{
public static void create(TableJB jb){}
public static TableJB read(int id){}
public static void update(TableJB jb){}
public static void delete(int id){}
public static List<TableJB> listAll(){}
}
The problem I see with this structure is that I will be having the connection management (opening and closing) in each of these methods, it seems wrong in my perspective (as if someone else should be handling these) and I am far from sure if this is the better practice. Also I wonder if I am supposed to re-validate data before writing it the database in case that client validations were disabled for some reason (e.x: by disabling JavaScript)?
As an important note: I am not allowed to use any framework for my solution (so no Spring, Hibernate, etc.).