Hello

For some time now I have implemented the Tomcat 'JNDI DataSource' How-To on
connection pooling, and everything has been fine.

I define a resource in the context fragment:


    <Resource name="jdbc/postgres"
              auth="Container"
              type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/postgres">
        ...
    </ResourceParams>
    

And a resource reference to it in the deployment descriptor:


    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/postgres</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>


And then do a JNDI lookup at runtime:


    return ( DataSource )new InitialContext().
        lookup( "java:comp/env/jdbc/postgres" );
    

Magic.

The other day I noticed that the resource reference in my deployment
descriptor was actually broken - the name did not match that defined in the
context - and yet my application was still working - perfectly.

When I thought about it, it occurred to me that the resource reference in
the deployment descriptor may not actually be necessary.

So I deleted the resource reference from the web.xml file, and everything
still works as expected.

Can anyone enlighten me?

Many thanks in anticipation.

Harry Mantheakis
London, UK





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to