Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

上記のMySQLデータベースへJNDIデータソースの接続を確立するためには、以下のコンテンツに従いリソースXML要素を作成します。

 <Resource

Code Block
languagesql
<Resource
name="jdbc/classicmodels"

...


auth="Container"

...


type="javax.sql.DataSource"

...


maxActive="100"

...


maxIdle="30"

...


maxWait="10000"

...


driverClassName="com.mysql.jdbc.Driver"

...


url="jdbc:mysql://localhost:3306/classicmodels"

...


username="root"

...


password="root"

...


/>

 

 

この要素を、「context.xml」ファイルのルート要素<Context>内に追加します。context.xmlファイルは、以下の2箇所に配置することができます(存在しない場合は作成します)。

...

web.xmlファイル(appserver/webapps/ROOT/WEB-INF/web.xml)に、以下の設定を追加します。

 

Code Block
languagesql
<resource-ref>

...


<description>DB Connection</description>

...


<res-ref-name>jdbc/classicmodels</res-ref-name>

...


<res-type>javax.sql.DataSource</res-type>

...


<res-auth>Container</res-auth>

...


</resource-ref>

 

 

これは、特定の名前空間「jdbc/classicmodels」下でアプリケーションがJNDIデータソースを利用できるようにするために必要な設定です。

...