users@glassfish.java.net

Re: DataSource Issue

From: <glassfish_at_javadesktop.org>
Date: Mon, 19 Apr 2010 12:45:18 PDT

For quick testing,

@Resource(lookup="jdbc/sqlserver")
private DataSource ds;

assuming jdbc/sqlserver is the name of the datasource that you created in GF.

For more flexible and portable app,

@Resource(lookup="java:comp/env/jdbc/sqlserver")
private DataSource ds;

IF:
(1) jdbc/sqlserver is the name of the datasource that you created in GF
(2) you declared a resource-ref in web.xml, whose res-ref-name is jdbc/sqlserver
(3) you also have a sun-web.xml containing a <resource-ref> element to map the res-ref-name in (2) to the jndi-name (jdbc/sqlserver) in (1)
[Message sent by forum member 'cf126330']

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