Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Anchor
top
top

Table of Contents
classcontents

 

様々なデータソース接続と合わせて、YellowfinではJNDI(Java Naming and Directory Interface)データソースを作成することができます。このタイプの接続は様々な用途に利用され、異なる環境(開発、統合、テスト、本番など)間でのアプリケーション移行や、外部のディレクトリサービスへの接続に使用されます。

...

今回の例では、「classicmodels」という名前のMySQLデータベースを使用して、JNDI接続を確立します。

 

Image Added

 

  • ステップ1:コンテキストの設定

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

 

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データソースを利用できるようにするために必要な設定です。

...

java:comp/env/jdbc/classicmodels

 

Image Added