in my project I have used EJB ( CMP ) ,, now my manager wants to 'remove ' the EJB part for 1-2 module of the project OK ? now that means from java program I have to access a DAO and from a DAO I will access the database . is this approach ok ? I know core java and part of EJB which I have worked on . not much
Or you could rewire your exiting beans to use something like Hibernate. You will need to rethink session/transaction handling, though. In the EJB world it's common to leave that to the container - without one, that's the responsibilty of your code.
This kind of problems require some analysis but here is an oversimplified answer: Look at your EJB CMP layer and think about the things it's doing. In most cases, CMP EJBs, 1. Capture the domain model as EJBs 2. Define mappings to map EJBs to the database tables 3. Container takes care of executing transactions etc.
If you want to move away from CMP EJBs you will have to think of ways to do these things in your code. Here is what I would propose: 1. Create a layer of domain layer POJOs. If you had say AccountEJB, you will now have AccountVO. Note that you can still have primary key class etc. like you did before 2. Create a way to map VOs to database tables. This can be done by either creating a layer of DAOs and writing JDBC code in them OR by using a framework such as Toplink or Hibernate 3. Create a layer of stateless session beans (you probably have this already), which would either access DAO or invoke Hibernate to perform CRUD operations. Define transactions etc. on sessions beans
To specifically, answer your question, yes, you can use Java code - DAO - database as long as you take care of transactions etc.
Hope this helps, let me know if you have more questions...