aspose file tools*
The moose likes Struts and the fly likes Database access in Struts -- best/common practice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Database access in Struts -- best/common practice?" Watch "Database access in Struts -- best/common practice?" New topic
Author

Database access in Struts -- best/common practice?

John Fontana
Ranch Hand

Joined: Feb 28, 2002
Posts: 235
I have seen many Struts example applications, and the database layer is always different -- some use Torque, others use JDBC calls within the FormBean. What is the most common solution? I am not using EJB's, and I understand that Struts is designed in such a way that you can use any data model...but in all methodologies there always seems to be the solution that works 90% of the time....any suggestions?


www.websiteandsound.com
"If you do what you've always done, you'll get what you've always gotten."
Michal Bienek
Greenhorn

Joined: Jun 17, 2002
Posts: 29
The best practice I've seen is to ensure complete seperation between the classes that access the database and Struts. In general, the best practice is to have DataAccessObjects (DAOs) access the database directly (and therefore hide the database interface completely from your application). These in turn should be called from a business object layer. Then the Struts Actions will talk to these business objects. That is by far the best layered approach.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database access in Struts -- best/common practice?