Thursday, December 12, 2002 08:22 AM
I use Datasource access stuff in my Data Access Object(DAO) class.
private void getDBConnection() throws MenuDAOSysException
DataSource ds=(DataSource) context.lookup("jdbc/SQLServerDS");
Below that I have closeDBConnection and closeDBStatement.
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
someObj=dao.getXXXX();//Note:-this getXXXX function's actual implemetation is in the DAO class.
getDAO() is also defined in the EJB implementation class
The implementation of getDAO is such:-
In ejb-jar.xml I have 'param/XXXDAOClass' mapped as an env-entry the value of which is XXXDAOSQLServer
Hope all that info helps. Also refer to DAO design pattern.