GlassFishのasadminコマンドでJDBC接続プールおよびJDBCリソースを作成します。作成したJDBCリソースをデータソースとして利用します。
asadminコマンドのcreate-jdbc-connection-poolサブコマンドおよびcreate-jdbc-resourceサブコマンドを使用して、アプリケーションで使用するJNDI名のJDBCリソースを作成してください。
詳細は“Interstage Application Server GlassFish設計・構築・運用ガイド”を参照してください。
下記にコマンド実行例を示します。太字部分はシステムにあわせて設定してください。
例
Symfoware Server (Postgres) を使用する場合
$ /opt/FJSViaps/glassfish5/glassfish/bin/asadmin create-jdbc-connection-pool \ --datasourceclassname org.postgresql.ds.PGPoolingDataSource \ --restype javax.sql.DataSource \ --property user=user001:password=abcd1234:databaseName=DB001:serverName=server01:portNumber=26500 \ spring_pool $ /opt/FJSViaps/glassfish5/glassfish/bin/asadmin create-jdbc-resource \ --target Cluster001 \ --connectionpoolid spring_pool \ jdbc/springAppDataSource |
Oracle Databaseを使用する場合
$ /opt/FJSViaps/glassfish5/glassfish/bin/asadmin create-jdbc-connection-pool \ --datasourceclassname oracle.jdbc.pool.OracleConnectionPoolDataSource \ --restype javax.sql.ConnectionPoolDataSource \ --property user=user001:password=abcd1234:URL=jdbc\:oracle\:thin\:@//server01\:1521/orcl \ spring_pool $ /opt/FJSViaps/glassfish5/glassfish/bin/asadmin create-jdbc-resource \ --target Cluster001 \ --connectionpoolid spring_pool \ jdbc/springAppDataSource |