• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO Pattern

 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
Basically getting ready for the OCPJP 7, I came across this topic "DAO Pattern" Database Access Pattern.
I understand that it uses the Abstract Factory Pattern in order to instantiate as many DAO object as needed (as many the database implementation requires).
However what about the JDBC connection?
Am I suppose to open and close a connection for each Factory method?(insert, update, delete, create)?
How would you proceed?

Thanks in advance.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A DAO deals with database connections. A factory has no business opening or closing or touching in a way your Connection.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data access object says -

Although this design pattern is equally applicable to most programming languages, most types of software with persistence needs, and most types of databases, it is traditionally associated with Java EE applications and with relational databases accessed via the JDBC API because of its origin in Sun Microsystems' best practice guidelines[1] ("Core J2EE Patterns") for that platform.



Regards,
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic