Skip to content

Instantly share code, notes, and snippets.

@rahulpandey
Created January 30, 2016 07:55
Show Gist options
  • Save rahulpandey/39706f452cbc75524e93 to your computer and use it in GitHub Desktop.
Save rahulpandey/39706f452cbc75524e93 to your computer and use it in GitHub Desktop.
1.Copy postgresql jar glassfish4/glassfish/domains/domain1/lib/ext
2.start glassfish
asadmin start-domain
3.Create Connection Pool (DataSource)
asadmin create-jdbc-connection-pool
--datasourceclassname org.postgresql.ds.PGSimpleDataSource
--restype javax.sql.DataSource
--property user=USER_NAME:password=PASSWORD:DatabaseName=DB_NAME:ServerName=HOST_NAME:port=PORT_NAME
postgresql-pool(DataSource Name)
Optional
4.Setting min/max sizes - via the command line
To set the initial & minimum pool size:
asadmin set resources.jdbc-connection-pool.test-pool.steady-pool-size=10
To set the maximum pool size:
asadmin set resources.jdbc-connection-pool.test-pool.max-pool-size=200
5.Connection Validation
asadmin set resources.jdbc-connection-pool.postgresql-pool.connection-validation-method=custom-validation
asadmin set resources.jdbc-connection-pool.postgresql-pool.validation-classname=org.glassfish.api.jdbc.validation.PostgresConnectionValidation
asadmin set resources.jdbc-connection-pool.postgresql-pool.is-connection-validation-required=true
You can also set whether to close all connections on failure with the following command:
asadmin set resources.jdbc-connection-pool.postgresql-pool.fail-all-connections=true
6.Statement and Connection Leak Detection
asadmin set resources.jdbc-connection-pool.postgresql-pool.statement-leak-timeout-in-seconds=5
asadmin set resources.jdbc-connection-pool.postgresql-pool.connection-leak-timeout-in-seconds=5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment