WTPでDataSource

Eclipse WTP で、DataSource を使う場合、
WebContent/WEB-INF/META-INF の下に、context.xml を置く。
Tomcat の場合、、
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="projectname" path="/Foo" reloadable="true" source="org.eclipse.jst.j2ee.server:sjp">
    <Resource   name="jdbc/foo"
                auth="Container"
                type="javax.sql.DataSource"
                factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://127.0.0.1:3306/FOO"
                username="abc"
                password="def"
                maxActive="20"
                maxIdle="10"
    />
</Context>
--------------
そして、web.xml に記述

    <resource-ref>
        <description>Foo DataSource</description>
        <res-ref-name>jdbc/foo</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

%TOMCAT_HOME%\common\lib に、必要なDBドライバクラスのJARを置く