-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Digilloyd,

On 7/31/2009 1:59 PM, DIGLLOYD INC wrote:
> Thank you.  Any snippet on the right way to to the Realm/Resource thing?
> It's been so long I don't remember the right way

Simple: just put this in your WEB-INF/context.xml file:

   <Resource name="jdbc/MyDataSource"
    description="[whatever]"
        auth="Container"
        type="javax.sql.DataSource"
        maxActive="1"
        maxIdle="1"
        maxWait="10000"
        url="@DATABASE_URL@"
        username="@DATABASE_USERNAME@"
        password="@DATABASE_PASSWORD@"
        driverClassName="@DATABASE_DRIVER@"
        removeAbandoned="true"
        removeAbandonedTimeout="30"
        logAbandoned="true"
    testOnBorrow="true"
    validationQuery="/* ping */ SELECT 1"
    />

Obviously, fill-in the appropriate values above.

You should also have in your web.xml something like this:

    <resource-ref>
           <description>[whatever]</description>
           <res-ref-name>jdbc/MyDataSource</res-ref-name>
           <res-type>javax.sql.DataSource</res-type>
           <res-auth>Container</res-auth>
    </resource-ref>

...but I've found that it is not strictly necessary. I think it's
because Tomcat knows that any <Resource> in WEB-INF/context.xml should
automatically be available in the visible JNDI context for the webapp.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkp3XxcACgkQ9CaO5/Lv0PDGcgCePI8NTUrVpCUyYKPBBOhhRnnW
aUQAoJAJEt2j0asnrgCDla49v5G1FQ7F
=F0rT
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to