users@glassfish.java.net

Re: JDBC via JNDI from Tomcat to Glassfish and back

From: Edson Carlos Ericksson Richter <edson.richter_at_mgrinformatica.com.br>
Date: Thu, 19 Apr 2007 10:01:25 -0300

Have you tried "java:comp/env/jdbc/postgres" ???

Regards,

Edson Richter


glassfish_at_javadesktop.org escreveu:
> I have a WAR that runs peachy under Tomcat 5.
>
> In WEB-INF/context.xml, I have a DBPool configured.
>
> <Context path="/cmsstr">
> <Resource auth="Container" driverClassName="org.postgresql.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/postgres" password="password" type="javax.sql.DataSource" url="jdbc:postgresql://localhost:5432/mydb" username="dbuser"/>
> </Context>
>
> In my WAR, I look up my data source like this:
>
> Context ctx = new InitialContext();
> DataSource ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/postgres");
>
> However, when I try to deploy this to Glassfish v1b14, I can not seem to duplicate the "java:/comp/env/jdbc/postgres". Glassfish won't let me use the ':'.
>
> Now, I'm not particularly passionate about what name I use, but I would like to know if there is a way I can configure both Tomcat and Glassfish so that I can run this code unchanged, using any name.
>
> I tried a ctx.lookup("jdbc/postgres"), but Tomcat couldn't find that, while Glassfish could.
>
> To be fair this aspect of JNDI has always been a wee bit cloudy to me regarding naming, default naming, required naming, etc.
>
> But if anyone could point the way to getting a common configuration, I'd appreciate it.
> [Message sent by forum member 'whartung' (whartung)]
>
> http://forums.java.net/jive/thread.jspa?messageID=213077
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>
>