users@glassfish.java.net

RE: Re: Glassfish Beginner Setup Question

From: Jason Lee <lee_at_iecokc.com>
Date: Thu, 8 Feb 2007 10:44:52 -0600

Try

dataSource =(DataSource)ctx.lookup(jndiName);

-----
Jason Lee, SCJP
Programmer/Analyst
http://www.iec-okc.com
 

> -----Original Message-----
> From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
> Sent: Thursday, February 08, 2007 10:22 AM
> To: users_at_glassfish.dev.java.net
> Subject: Re: Glassfish Beginner Setup Question
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>