ctx.lookup("java:comp/env/jdbc/MySQLDataSource");
for this to work, you will need to declare a resource-ref in web.xml whose res-ref-name is "jdbc/MySQLDataSource", and is somehow mapped to the jndi-name of the resource you just created. The mapping can be done in sun-web.xml. Any name under java:comp/env namespace is private to your webapp.
Alternatively, you can directly look up the jdbc resource using its jndi-name that you specified when creating this resource, at the expense of flexibility. for example,
lookup("jdbc/MySQLDataSource/world");
[Message sent by forum member 'cf126330']
http://forums.java.net/jive/thread.jspa?messageID=476817