Setting up Connection Pools on the Glassfish server
For efficiency and security reasons we use
PGConnectionPools which are started and configured on the glassfish Web Application server. The pools are made available to the webapplication or web service as
DataSources. Below is an example how to set up two such
ConnectionPools. One is for read access only (
DataSource) the other one allows to make changes (CRUD) to the database (
WriterSource) in this case the database is served by the localhost.
/asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGConnectionPoolDataSource --restype javax.sql.ConnectionPoolDataSource --property user=g4valreader:password=xxxxxx:url="jdbc\:postgresql\://localhost\:5432/g4validation" myjdbc_postgres-pool./asadmin create-jdbc-resource --connectionpoolid myjdbc_postgres-pool DataSource ./asadmin get domain.resources.jdbc-connection-pool.myjdbc_postgres-pool./asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGConnectionPoolDataSource --restype javax.sql.ConnectionPoolDataSource --property user=g4valwriter:password=xxxxxxx:url="jdbc\:postgresql\://localhost\:5432/g4validation" myjdbc_postgres-writerpool./asadmin create-jdbc-resource --connectionpoolid myjdbc_postgres-writerpool WriterSource ./asadmin get domain.resources.jdbc-connection-pool.myjdbc_postgres-writerpool
Web Application/ Web service only need to check that the resources
DataSource (reading) and
WriterSource (crud) are available → no info about database needed/exposed.
Node: This can not be done via the glassfish WEBAdmin GUI (bug) → need to use command line interface (see above)
--
HansWenzel - 2016-06-07