Resource-Ref is definately 2.3-standard.

Here's a configuration we're running in production. Adapt it to your
needs, should work with TC 5.5 and 6.x:

META-INF/context.xml:

<?xml version='1.0' encoding='utf-8'?>
<Context>
  <Resource
    auth="Container"
    description="somedescr"
    name="jdbc/someName"
    type="javax.sql.DataSource"
    factory="org.apache.commons.dbcp.BasicDataSourceFactory"
    driverClassName="com.mysql.jdbc.Driver"  <-- your driver here
    username="someUser"
    password="somePass"
    url="jdbc:mysql://db:3306/someDB" <-- your url here
    maxIdle="30"
    maxWait="10000"
    maxActive="10"
    validationQuery="SELECT 1"
    testOnBorrow="true"
    testWhileIdle="true"
    timeBetweenEvictionRunsMillis="10000"
    minEvictableIdleTimeMillis="28800"
    poolPreparedStatements="true"
    removeAbandoned="true"
    removeAbandonedTimeout="300"
    logAbandoned="false"/>
</Context>

You don't habe to specify the DS in your deployment-descriptor (web.xml) at all.

Within your servlet / jsp, your get a handle from the DS as follows:

Context env = (Context) new InitialContext()
                .lookup("java:comp/env");
DataSource dbDS = (DataSource) env.lookup(dataSourceName);

HTH

Gregor
-- 
just because you're paranoid, don't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available
@ http://pgpkeys.pca.dfn.de:11371
@ http://pgp.mit.edu:11371/
skype:rc46fi

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

Reply via email to