users@glassfish.java.net

RE: JNDI lookup, dependency injection, datasource

From: Sigal Shaharabani <Sigal.Shaharabani_at_Teledata-Networks.com>
Date: Tue, 15 Jun 2010 10:24:20 +0300

I'm also adding that even if your JDBC resource is a connection pool in
the code you should define the resource as DataSource
It's transparent in glassfish

P please consider the environment - do you really need to print this
email?
-----Original Message-----
From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
Sent: Tuesday, June 15, 2010 9:29 AM
To: users_at_glassfish.dev.java.net
Subject: Re: JNDI lookup, dependency injection, datasource

You can refer the tech tip :
http://blogs.sun.com/enterprisetechtips/entry/datasource_resource_defini
tion_in_java
and the sample
http://blogs.sun.com/enterprisetechtips/resource/DSD.zip
has web.xml, ejb-jar.xml with datasource-definition.

If you are injecting the resource, it should be on a Java EE component
eg: Servlet/EJB/AppClient

Snippet from the tech-tip :

"Note that the sample application does a lookup to get access to a
resource. However, it is also possible to inject the datasource as
follows :

   @Stateless
   public class HelloEJB implements Hello {

     @Resource(lookup = "java:app/env/HelloEJB_DataSource")
     private DataSource app;
   ...
   ...
   }
"
[Message sent by forum member 'jr158900']

http://forums.java.net/jive/thread.jspa?messageID=474280

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net