aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes DAO Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "DAO Pattern" Watch "DAO Pattern" New topic
Author

DAO Pattern

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

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.


OCAJP 7, OCPJP 7
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

A DAO deals with database connections. A factory has no business opening or closing or touching in a way your Connection.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1174
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


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
 
wood burning stoves
 
subject: DAO Pattern