File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Where do I put database calls in a Struts app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Where do I put database calls in a Struts app?" Watch "Where do I put database calls in a Struts app?" New topic

Where do I put database calls in a Struts app?


Joined: May 31, 2004
Posts: 9
I'm trying to learn how to put a web-app together using Struts.1. I have some questions about where the connectivity to the database should go.
2.Using DynaActionForm in struts.
anyone to know this please help me...
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
See coming to DB struts has nothing to do with but its always better not to put much logic in ur a ction class so its better to isolate the DB connectivity from the action and place in any utility class

coming to DynaActionForms there is a tradeoff .....this reduces the writing of form class but now u have many IDEs which gen set and get methods and that too in the future if u need to change some field changing in xml needs restart of webserver while its not in the case of ActionForm

so u decide up on this and u can proceed
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Hello "feena" and welcome to the JavaRanch!

I noticed you have missed our naming policy so I'd like to ask you to drop by at My Profile and edit your display name so that it complies with the "first name and last name required" rule.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
I tend to use four java classes for almost each page.


Where object is the general name of what you're doing.

I place all my database calls and such within the file. Keeps things clean, organized, and lets me extend off of a pre-made template with all my connection information and such.
It is sorta covered in the JavaRanch Style Guide.
subject: Where do I put database calls in a Struts app?
It's not a secret anymore!