aspose file tools *
The moose likes JDBC and the fly likes How automatically DAO methods get called upon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How automatically DAO methods get called upon" Watch "How automatically DAO methods get called upon" New topic
Author

How automatically DAO methods get called upon

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
I am new to Java J2EE development , so please help me even my doubt is a prank

Here is my query :

I have a DAO to perform operations on database :



and i have a class that implements this MyDAO



I want to know upon calling a DAO interface from the servlets (Correct me if i am wrong) how the DAO implementation class would be get called upon ?
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Is my query so complicated or foolish as nobody is interested in replying.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
1) Do not doublepost the same question over all forums. This will waste other's time which is rude.
2) Do not impatiently kick topics up. Chance to get ignored is bigger.
3) Write proper English and use proper Java terms. Your question is vague.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
How can i find a answer for this ??
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If you elaborate the question more clearly, you would likely generate more useful response.

Your last sentence "I want to know upon calling a DAO interface from the servlets (Correct me if i am wrong) how the DAO implementation class would be get called upon ? " is a bit too vague. Af far this sounds like that you wanted to know how something like "MyDAO myDAO = new MyClass();" is to be done, but this is too obvious that I am unsure about what you're actually asking.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212

I will let you explain what is the confusion going on my mind :


Inside my servlet i have like this

if(reques.getParameter("ButtonName").equals("SerachEmployees"))
{
// Here i am calling a method on the DAO interface
List list =MyDAO.getData(Employee employee);
}

How the implementation class is getting called upon ?

what i am doing is right or wrong ?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You just instantiate it. You can do it yourself or using a DAO factory based on the input or configuration parameters. You can do that in the init() method of the servlet and assign it as instance variable of the servlet.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Didn't get you at all . Is there any link or tutorial for this ?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I now see a private message from you with the question not to respond on your posts anymore. Not that this is a big problem, you've it in your hands, but what on earth happened?

At any way, here is a simple (pseudo)example of just instantiating it in the servlet's init().



More examples about the DAO can be found here http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Bauke Scholtz wrote:I now see a private message from you with the question not to respond on your posts anymore. Not that this is a big problem, you've it in your hands, but what on earth happened?


I did a lot of googling before sleep, but didn't found suitable answer so the reason posted on to the site and in the morning saw the reply from you .
Thanks .
 
 
subject: How automatically DAO methods get called upon