You can specify a custom implementation for Connection Validation that is faster or optimized for a specific database. Set the Validation Method attribute to the value custom-validation. (Other validation methods available are table (the default), auto-commit, and meta-data.) The GlassFish Server provides a public interface, org.glassfish.api.jdbc.ConnectionValidation, which you can implement to plug in your implementation. A new attribute, Validation Classname, specifies the fully qualified name of the class that implements the ConnectionValidation interface. The Validation Classname attribute is required if Connection Validation is enabled and Validation Method is set to Custom Validation.
To enable this feature, set Connection Validation, Validation Method, and Validation Classname for the JDBC connection pool in one of the following ways:
Enter Connection Validation, Validation Method, and Validation Classname values in the Edit Connection Pool Advanced Attributes page in the Administration Console. You can select from among validation class names for common databases in the Validation Classname field. For more information, click the Help button in the Administration Console.
Specify the ----isconnectionvalidatereq, ----validationmethod, and ----validationclassname options in the asadmin create-jdbc-connection-pool command. For more information, see the Oracle GlassFish Server 3.0.1 Reference Manual.
Specify the is-connection-validation-required, connection-validation-method, and validation-classname options in the asadmin set command. For example:
asadmin set domain1.resources.jdbc-connection-pool.MyPool.is-connection-validation-required=true asadmin set domain1.resources.jdbc-connection-pool.MyPool.connection-validation-method=custom-validation asadmin set domain1.resources.jdbc-connection-pool.MyPool.validation-classname=impl-class |
For more information, see the Oracle GlassFish Server 3.0.1 Reference Manual.
By default, optimized validation mechanisms are provided for Java DB, MySQL, Oracle, and PostgreSQL databases. Additionally, for JDBC 4.0 compliant database drivers, a validation mechanism is provided that uses the Connection.isValid(0) implementation.