users@glassfish.java.net

Re: GlassFish v3 JDBC Resource

From: <glassfish_at_javadesktop.org>
Date: Wed, 10 Feb 2010 19:30:30 PST

Also, if you are using a standard Java EE component (web/ejb), you can set the "authentication" mode <res-auth> to "Application" which indicates that the application will provide necessary credentials.

eg: you can specify the following in ejb-jar.xml / web.xml
 <resource-ref>
        <res-ref-name>DataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Application</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

By doing so, application can do component managed authentication as follows :
datasource.getConnection("user","password");
[Message sent by forum member 'jr158900' (Jagadish.Ramu_at_Sun.com)]

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