users@glassfish.java.net

Re: Glassfish Beginner Setup Question

From: <glassfish_at_javadesktop.org>
Date: Thu, 08 Feb 2007 08:22:26 PST

I get an exception looking up: jdbc/myDB

Part of the problem may be that I'm porting some 3rd party code that worked on Resin to Glassfish. This used to work there.

Is this the correct way to lookup the myDB?
Here, jndiName is "jdbc/myDB" as specified in web.xml.


// Create a default initial context
InitialContext ctx = new InitialContext();

// Lookup the DataSource
dataSource =(DataSource)ctx.lookup("java:comp/env/" + jndiName);

// Throw an Exception if not found
if (dataSource==null) {
throw new DatabaseException(
        DatabaseException.COULD_NOT_FIND_DATA_SOURCE, jndiName, null);
}
[Message sent by forum member 'tmonteit' (tmonteit)]

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