Discussions

EJB design: How to make all EJB lookup a datasource?

  1. Hello dudes, i'm trying to make my beans lookup a database's conection, but the point here is make all of them see my jdbc/Datasource

      Any idea?

      Regards,
      lottalava
  2. One approach is to have an abstract class and define all your common methods for getting a database connection, ejbCreate() and other EJB lifecycle methods in the class. Next have all your EJB's extend this class so no need to write the same code in every EJB.
  3. That´s ok, but may point here is about <resource-ref>, if i do what you wrote above, i still need to put a <resource-ref> in every bean inside my ejb-jar.xml, i´d like to create only one <resource-ref> to all beans, something like <resource-ref> in web.xml, to solve that i made a special bean where all others ask for database connections.