I have a question.
I want use a method from a class, using its interface ( for istantiate it) after i have used a factory class.
Example:
public class UserBusiness{
DAO_Interface DAO = DAO_Factory.getDAO("USER");
public User Login(User user){
User userx = DAO.LoginDAO(user);
return userx;
}
}
public class DAO_Factory {
public static DAO_Interface getDAO(String type) {
switch(type){
case "USER" : {
return new DAO_User();
}
public class DAO_User implements DAO_Interface{
User userx;
public DAO_User() { }
public User LoginDAO(User user){
// find data from Database
return userx;
}
@Override
public Connection getConnetion() {
// TODO Auto-generated method stub
return null;
}
}
public interface DataAccessObject {
Connection getConnetion();
}
why don't work? i want use Interface only for method to connect every DAO(concrete) with database. Because i'm using many Entity class (as like as User), and only UserDao use a EntityClass User.
thanks a lot.
Aucun commentaire:
Enregistrer un commentaire