wood burning stoves 2.0*
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
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
Author

Where do I put database calls in a Struts app?

mareena
Greenhorn

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
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.

Thanks!


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.

[object]Action.java
[object]Form.java
[object]DTO.java
[object]Service.java

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

I place all my database calls and such within the service.java file. Keeps things clean, organized, and lets me extend off of a pre-made template with all my connection information and such.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Where do I put database calls in a Struts app?
 
Similar Threads
Poll: Do JSF and Struts need their own forums?
Bean in application scope
Moving to Struts
Database connection in struts?
Unable to load configuration. - [unknown location]