And then I call the DB accessing function in same class.The class implements an interface..XXXDAO.java(where XXX is some name)and this class is for SQLServer(and so I called this as XXXDAOSQLServer.java)

In the implementation class of EJB, in the function that is supposed to access DB data, I have

XXXDAO dao=getDAO();

someObj=dao.getXXXX();//Note:-this getXXXX function's actual implemetation is in the DAO class.