In regards to Wendy's statement: "That may be overkill for a simple app where you might put JDBC code directly in the Action class."
Simple Applications Grow into Five Headed Monsters: I just wanted to agree with Wendy and encourage the use of DAO or some sort of separated database access (DAO,OJB,etc...) even in "simple" applications. I develop websites for small to mid-sized businesses. I made the Struts newbie mistake of placing all my "logic"/database access in my action classes. As my "simple" applications grew I began to see how much I was tying myself down by making my Actions synonymous with my logic. To make a long story short. I had a bunch of code buried in my Action classes that ultimately needed to be shared amongst several web-apps running on the same server. Early on I had seen the growing complexity of my "simple" applications and I began using the DAO pattern to seperate out my database access (along with implementing some other clever patterns I picked up round these newsgroups). In the end I had to take two large chunks of code out of one of my webapps so that I could share it with several other webapps. I wrote a couple of main classes that read in some configuration files to perfrom automated data retrieval with my DAO/logic classes, set up a cron job and wham-o no painful translation from Action to standalone classes just the sweet ease of a pattern gone well. In the end... try to follow the pattern even if it seems overkill... cuz it has a higher probability of pay off when your app grows a few more heads than you expected. :-D I think we all know that story. Brandon Goodin Phase Web and Multimedia P (406) 862-2245 F (406) 862-0354 [EMAIL PROTECTED] http://www.phase.ws -----Original Message----- From: Wendy Smoak [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 3:16 PM To: 'Struts Users Mailing List' Subject: RE: newbie about struts and databases > hi, i'm starting in Struts, and am reading the tutorials in the struts > site about building applications with it, and i was thinking if there is > any easy tutorial about database access using struts, so i can start > more rapidly with it (and my boss doesn't get mad at me while > convincing him to use struts in the new project we are starting ;) Been there... :) And discovered that there really isn't any "database access using Struts". Your data access solution shouldn't have anything to do with Struts. It should be usable from a Struts Action, from a Swing app, from a console app, etc. Personally, I implemented the "Data Access Object" pattern as shown in the J2EE Blueprints document. That may be overkill for a simple app where you might put JDBC code directly in the Action class. Or something in between. The problem with the existing examples is that they have comments such as, "In a real-world application, we wouldn't do this, but for the purposes of this example..." And nobody ever shows you how you WOULD do it in the real world, because it's messy and complicated and depends on your data structures and rules. So if you haven't determined how you're going to access your database, do that first, separately, before you try to access your database from Struts. -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University PA Information Resources Management -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>