• Post Reply Bookmark Topic Watch Topic
  • New Topic

DAOs and Datasources  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I want to use DAO pattern in EJB and servlets components.
I know how to implement DAO, but I am not sure if I can use datasource or connection pools inside DAOs.
to use a datasource in EJBs or Servlets, we add a datasource to the container , then we add some entries to ejb-jar.xml or web.xml files, then use JNDI.
but how to use a datasource inside a DAO ?
just use the normal code like :
Context ctx = new InitialContext( );
DataSource ds = (DataSource)ctx.lookup("java:com/env/jdbc/ToddDB");
its work ??
thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!