5.3.1.1. DataSource¶
intra-mart Accel Platform で利用するデータベースの設定を行います。
5.3.1.1.1. 接続先の種類¶
intra-mart Accel Platform では、以下の3種類のデータベースに接続できます。
システムデータベース
システムのデータを保存するデータベースです。アプリケーション起動時にあらかじめ接続可能となっている必要があります。システムデータベースはシステム内部で利用されるため、本番環境等ではアプリケーションの接続先としては推奨しません。テナントデータベース
テナント内で利用するデータを保存するデータベースです。シェアードデータベース
intra-mart Accel Platform 外のデータを保存するデータベースです。外部システムと連携したい場合等に利用します。注意
ViewCreator/TableMaintenance等で利用できる データベース はテナントデータベースとシェアードデータベースが対象です。システムデータベースとテナントデータベースを同じ接続先として設定することは可能ですが、 システムデータベースとして作成されるテーブルの利用はサポート対象外です。
5.3.1.1.2. DataSourceの設定¶
「ProjectNavigator」内の <(プロジェクト名)/resin-web.xml> ファイルをダブルクリックで開き、「ソース」タブを選択してください。
<web-app>/<database>/<driver> に接続先のデータベース接続情報を設定します。以下は各データベース毎の接続例です。コラム
- バーチャルテナントによる複数テナント の場合
テナント数分、DataSourceを準備してください。各テナント毎に利用するDataSourceを設定してください。コラム
弊社では、Resin 4.0.56 以降で PostgreSQL, Oracle, Microsoft SQL Server の設定として ConnectionPoolDataSource の利用を推奨します。Resin 4.0.55 以前では、java.sql.Driver を利用してください。Resin 4.0.56 以降で、java.sql.Driver を利用することも可能です。注意
resin-web.xml ではプリペアドステートメントキャッシュに関する以下の設定の初期値として 0 が設定されています。
- database/prepared-statement-cache-size
- database/driver/preparedStatementCacheQueries
これは、以下の事象を回避するための設定値です。プリペアドステートメントキャッシュ設定を 0 に指定している場合、データベースに問い合わせを行う際のパフォーマンスが低下します。テナント環境セットアップ後は、適切にプリペアドステートメントキャッシュ設定を行ったデータソースを利用することを推奨します。
5.3.1.1.2.1. PostgreSQL¶
次のフォーマットを利用して、データベースURLを指定します。jdbc:postgresql://<host>:<port>/<databasename>
Resin 4.0.56 以降をご利用の場合の設定例は、以下のとおりです。<driver> <type>org.postgresql.ds.PGConnectionPoolDataSource</type> <url>jdbc:postgresql://localhost:5432/iap_db</url> <user>imart</user> <password>imart</password> <preparedStatementCacheQueries>0</preparedStatementCacheQueries> </driver> Resin 4.0.55 以前をご利用の場合の設定例は、以下のとおりです。
Version 9.4-1202 以降
<driver> <type>org.postgresql.Driver</type> <url>jdbc:postgresql://localhost:5432/dbname</url> <user>username</user> <password>password</password> <init-param> <param-name>preparedStatementCacheQueries</param-name> <param-value>20</param-value> </init-param> </driver>Version 9.4-1201 以前
<driver> <type>org.postgresql.Driver</type> <url>jdbc:postgresql://localhost:5432/dbname</url> <user>username</user> <password>password</password> </driver>コラム
java.sql.Driver を利用する場合 JDBC ドライバのバージョンによって設定が異なります。Version 9.4-1202 以降では <init-param> に preparedStatementCacheQueries を設定する必要があります。詳しくは、「設定ファイルリファレンス」の「プリペアドステートメントキャッシュ設定」を参照してください。
5.3.1.1.2.2. Oracle¶
システム識別子(SID)で接続する場合は次のフォーマットを利用して、データベースURLを指定します。jdbc:oracle:thin:@<host>:<port>:<SID>以下は、記述例です。<driver> <type>oracle.jdbc.pool.OracleConnectionPoolDataSource</type> <url>jdbc:oracle:thin:@localhost:1521:orcl</url> <user>username</user> <password>password</password> </driver>サービス名で接続する場合は次のフォーマットを利用して、データベースURLを指定します。jdbc:oracle:thin:@//<host>:<port>/<service>
Resin 4.0.56 以降をご利用の場合の設定例は、以下のとおりです。<driver> <type>oracle.jdbc.pool.OracleConnectionPoolDataSource</type> <url>jdbc:oracle:thin:@//localhost:1521/orcl</url> <user>username</user> <password>password</password> </driver> Resin 4.0.55 以前をご利用の場合の設定例は、以下のとおりです。<driver> <type>oracle.jdbc.driver.OracleDriver</type> <url>jdbc:oracle:thin:@//localhost:1521/orcl</url> <user>username</user> <password>password</password> </driver>
5.3.1.1.2.3. Microsoft SQL Server¶
次のフォーマットを利用して、データベースURLを指定します。jdbc:sqlserver://<host>:<port>;DatabaseName=<databasename>
Resin 4.0.56 以降をご利用の場合の設定例は、以下のとおりです。<driver> <type>com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource</type> <url>jdbc:sqlserver://localhost:1433;DatabaseName=databasename</url> <user>username</user> <password>password</password> <selectMethod>cursor</selectMethod> <sendTimeAsDatetime>false</sendTimeAsDatetime> </driver> Resin 4.0.55 以前をご利用の場合の設定例は、以下のとおりです。<driver> <type>com.microsoft.sqlserver.jdbc.SQLServerDriver</type> <url>jdbc:sqlserver://localhost:1433;DatabaseName=databasename</url> <user>username</user> <password>password</password> <init-param> <param-name>SelectMethod</param-name> <param-value>cursor</param-value> </init-param> </driver>
5.3.1.1.2.4. SAP HANA¶
次のフォーマットを利用して、データベースURLを指定します。jdbc:sap://<host>:<port>?currentschema=<schemaname>以下は、記述例です。<driver> <type>com.sap.db.jdbc.Driver</type> <url>jdbc:sap://localhost:30015?currentschema=schemaname</url> <user>username</user> <password>password</password> </driver>
コラム
5.3.1.1.3. DataSourceマッピングの設定¶
「ProjectNavigator」内の <(プロジェクト名)/conf/data-source-mapping-config.xml> ファイルをダブルクリックで開き、「ソース」タブを選択してください。 DataSourceとして設定したJNDI名を指定します。システムデータベースとテナントデータベース毎に設定したDataSourceを指定します。
WebSphere Application Server 9.0.5 の場合
<data-source-mapping-config>/<system-data-source>/<resource-ref-name> にシステムデータベースのJNDI名を設定します。
<system-data-source> <resource-ref-name>jdbc/default</resource-ref-name> </system-data-source><data-source-mapping-config>/<tenant-data-source>/<resource-ref-name> にテナントデータベースのJNDI名を設定します。
<tenant-data-source> <tenant-id>default</tenant-id> <resource-ref-name>jdbc/default</resource-ref-name> </tenant-data-source>注意
WebSphere Application Server 9.0.5 の場合、<resource-ref-name> には「java:comp/env/」を除去したJNDI名を指定する必要があります。WebSphere Application Server 9.0.5 以外の場合
<data-source-mapping-config>/<system-data-source>/<resource-ref-name> にシステムデータベースのJNDI名を設定します。
<system-data-source> <resource-ref-name>java:comp/env/jdbc/system</resource-ref-name> </system-data-source><data-source-mapping-config>/<tenant-data-source>/<resource-ref-name> にテナントデータベースのJNDI名を設定します。
<tenant-data-source> <tenant-id>default</tenant-id> <resource-ref-name>java:comp/env/jdbc/tenant</resource-ref-name> </tenant-data-source>注意
<tenant-id> には、初回で作成するテナントIDを設定してください。注意
Oracle WebLogic Server 12c R2(12.2.1), WebSphere Application Server 9.0.5 ではシステムデータベースとテナントデータベースは同一のデータベースを指定してください。詳細は以下を参照してください。