9章 データベースへの接続
9.2 JDBCの利用
9.2.1 SQLの実行
9.2.2 問い合わせ結果の処理
9.3 スクリプトレットでの実装
コネクション・プール
コネクション・プールの設定
接続を長時間有効にしておけるように、context.xmlの内容を修正しています。( 「autoReconnect=true」という記述は使えなくなるようです。参考: TomcatでConnector/Jを使用する)
コネクション・プールの利用
コネクション・プールの効果
context.xml (DB2)
<?xml version="1.0" encoding="UTF-8"?> <Context path="/myweb" docBase="myweb" reloadable="true"> <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" driverClassName="com.ibm.db2.jcc.DB2Driver" url="jdbc:db2:mydb" username="test" password="pass" removeAbandoned="true" removeAbandonedTimeout="10" logAbandoned="true" maxActive="10" maxIdle="10" maxWait="10000" /> </Context>
