DataSource
Tomcatでは context.xml に記述した設定から読み込み可能
各webapp の /META-INF/context.xml
TOMCAT の conf/context.xml
どちらか
グローバル設定は
TOMCAT conf/server.xml の <Resource>
PostgreSQL側のorg.postgresql.ds.PGPoolingDataSource などは使っていない手順
context.xml 単体
code:META-INF/context.xml
<Context>
<Resource name="jdbc/db1" auth="Container"
type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/db1"
username="user1" password="password1"
maxTotal="20" maxIdle="10" maxWaitMillis="-1"
/>
</Context>
name JNDI名
auth Container
type DataSource
driverClassName JDBCドライバのClass
factory DataSource のclass
url JDBC URL
username, password JDBCのuser
maxTotal maxIdle maxWaitMillis 同時接続数など
driverClassName より factory でJDBCドライバのDataSourceを指定したいところ
WEB-INF/lib または Tomcatの lib にJDBCドライバを入れておく
conf/server.xml に設定する場合は
<Resource global="jdbc/db1" /> のパラメータを追加する
conf/context.xml <ResourceLink name="jdbc/db1" global="jdbc/db1" auth="Container" type="javax.sql.DataSource" />
global で conf/server.xml の設定とリンクする