• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help on DAO

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am in fond of learning DAO and trying to implement it in my project. I don't know where to start. Before that I'll just brief my expertise level. I know Core Java and I had done 4 to 5 projects in JSP and Servlets. If I want to learn DAO, what are the things I have to learn before hand. Because While I try to learn DAO in some tutorial, I came to know lot of new things came which I never learnt like JTA, JDO, EJB, JNDI ....

And I want some basic tutorial for learning DAO, I had searched in google, but I didn't find any simple or basic tutorial for beginners. The one from IBM and Sun Site seems to not clear for me. Any other tutorial/links/ will be useful and also suggest, for learning DAO, I have to learn any other thing before hand or is't ok if Core Java,jsp and servlet is sufficient.
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know servlets, and you want to learn how to write and use DAOs, the easiest next step is to be sure you understand how to write JDBC code, since you can't access a database without some form of code to handle the database interaction. There are obviously ways you can write DAOs without JDBC (JDO, Spring, Hibernate, ...), but from the standpoint of learning how this technology works, I think it makes sense to at least try it in JDBC first. All the other options internally will be using JDBC in some form or another; at least this way you'll have a mental model for what is going on when you shift to more powerful/more convenient options.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply.
I know JDBC to certain extend. Now I am using Connection pooling for getting the connection. I have written one separate class for connection pooling. For example: If I want want to add the customer details in the database, I will write one servlet for Customer, which will have insert query for inserting into DB That are all working fine. For deletion/Modification, I will use Delete/Update query in the Customer Servlet itself.

So, I know JDBC also to certain extend. I am not find any good tutorial like step by step procedural of how to write the DAO pattern. Other wise, I want some good books for DAO pattern. pls suggest some good books for DAO for beginners.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at Core J2EE Patterns - Data Access Object.
 
Pj Murray
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Reid M. Pinchback:
If you know servlets, and you want to learn how to write and use DAOs, the easiest next step is to be sure you understand how to write JDBC code, since you can't access a database without some form of code to handle the database interaction. There are obviously ways you can write DAOs without JDBC (JDO, Spring, Hibernate, ...), but from the standpoint of learning how this technology works, I think it makes sense to at least try it in JDBC first. All the other options internally will be using JDBC in some form or another; at least this way you'll have a mental model for what is going on when you shift to more powerful/more convenient options.



This is excellent advise. Even if you decide to use an ORM solution later on, you really should understand JDBC. You'll find many situations where straight JDBC DAOs are the best choice.
 
Michael Duffy
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Henryson:
Hi,
Thanks for your reply.
I know JDBC to certain extend. Now I am using Connection pooling for getting the connection. I have written one separate class for connection pooling. For example: If I want want to add the customer details in the database, I will write one servlet for Customer, which will have insert query for inserting into DB That are all working fine. For deletion/Modification, I will use Delete/Update query in the Customer Servlet itself.

So, I know JDBC also to certain extend. I am not find any good tutorial like step by step procedural of how to write the DAO pattern. Other wise, I want some good books for DAO pattern. pls suggest some good books for DAO for beginners.



You should not be using a connection pool that you wrote. Better to use a production-quality one like Jakarta's DBCP.

Servlets should not have queries in them. What will you do if you decide to reuse those database actions outside a web context?

How hard can it be? All DAOs have a similar basis:



You'll have more find methods for each WHERE clause.

No books. Google for it - it's on the Web.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic