• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

To DAO or not to DAO

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
After a half day crashcourse on java and j2ee I am now trying to figure out what I was told last week.
I am trying to work along the example of Jakarta Struts Live, as is available as a PDF.
In the example there is some code that creates a DAO:

UserDAO dao=DAOFactory.createUserDAO(conn);
Eclipse (which we have to use at work) complains that it cannot resolve DAOFactory.

An equal problem I encounter with

private static Log log =
LogFactory.getLog(AdminUsersAction.class);
Here Eclipse moans that LogFactory cannot be resolved.

I am probably missing a couple of things that need to be imported. So far I have this:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import java.util.*;
import org.apache.log4j.*;

These 2 errors are just the start of all my problems, but well, you have to start somewhere... Thanks for hints, tips, pointers and such.

Paul
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LogFactory:

On page 15 of Jakarta Struts Live in the "Run and Test Your First Struts Application" section (I did a search for LogFactory in the pdf and this is the first reference) it shows the code importing LogFactory (not shown in later code snippets),

import org.apache.commons.logging.LogFactory;

Your code had a log4j import rather than a commons logging import.

DAOFactory:

p. 51 "Applying JUnit to Our Struts Tutorial" shows the first use of DAOFactory. Page 53 shows the code for DAOFactory that you get to write.
You'll need to import it if you put it in a different package from the action. If you're on page 51 of the tutorial eclipse or your compiler is supposed to complain, see this on p. 52 "At this point, we are calling methods that do not exist yet...This is a common technique in TDD. You define tests before you define the code...." See the tips on page 52, eclipse may help you stub out stuff that does not exist.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Never mind]
[ April 22, 2005: Message edited by: Marc Peabody ]
 
Paul Kater
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carol,
Thanks for the information. Looks like I need to speak to the person that told me to just go through several defined chapters. That is how I missed the information you pointed out.
Paul
 
reply
    Bookmark Topic Watch Topic
  • New Topic