• 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

Simple Question Regarding DAO (Data Access Object)

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Data Access Object (DAO) means the object has only data access logic. No business logic in it at all.
I want to implement this method:

in the DAO with this query statement:

which looks under the "user_name" field in the "members" table for the username that is supplied by the calling class.
I have rs.next() to loop through every single record in the "members" table to look for that particular record. If username cannot be found in the "members" table, I have this statement:

Is my DAO considered to have data access logic only (no business logic at all)?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JiaPei,
You DAO doesn't really contain any business logic. However, it might be better to return null if there is no username found (or throw an exception.) That way the caller could do whatever is appropriate. It might want to print a message, but it might want to do something else.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Jeanne, for taking a look at my code and confirm what I am doing. I do return null if the username cannot be found in the database.
 
Ranch Hand
Posts: 427
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My article, Advanced DAO Programming, discusses the DAO pattern:
http://www-106.ibm.com/developerworks/java/library/j-dao/
 
reply
    Bookmark Topic Watch Topic
  • New Topic