Tomcat 6.0.18データソースの構成


ステップ1:%Tomcat_HOME%conf\context.xmlのContextラベルには、次のコードが追加されています.
<Resource  name="jdbc/starnet" auth="Container" type="javax.sql.DataSource"
     		username="myuser"
     		password="123456"
     		url="jdbc:mysql://localhost:3306/test"
     		driverClassName="com.mysql.jdbc.Driver"
     		maxIdle="30"
     		maxWait="5000"
     		maxActive="100"/> 

第2歩:アプリケーションディレクトリの下のwebを構成する.xmlファイル、の間に次のコードを追加します.
<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/starnet</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

 
注意:jdbc/starnetの「jdbc/starnet」はcontextに必ず従うことが要求される.xmlで構成されているResourceのnameは一致しています.そうしないとエラーが発生します.