Custom Validation in GlassFish V3
By shalini_m on Dec 15, 2009
Connection Validation mechanism in GlassFish has been extended to provide a new type of validation mechanism – Custom Validation. Users can provide their own implementation to validate a connection during each application request.
During times when database server is restarted or a network failure, connections could become stale in the connection pool. When such connections are used by the applications, exceptions are thrown that connection got is invalid. There are types of connection validation mechanisms already existent in GlassFish : autocommit, metadata and table.
The connection-validation-method attribute can be set to custom-validation. This validation mechanism could could aid users to implement faster validation routines. If connection validation fails, pooling infrastructure will return the next valid connection or create a new connection to return to the application.
GlassFish provides a public interface org.glassfish.api.jdbc.ConnectionValidation for the users to implement and provide value to an attribute validation-classname.
Setting Custom Validation
Turn on Validation, set validation type to custom-validation and set an appropriate implementation class with the entire package name to validation-classname.
In Admin console (http://localhost:4848) Connection validation settings can be made in the advanced tab.
Custom Validation mechanisms in GF
There are some default validation mechanisms provided by GlassFish for the users to use for certain databases. These are listed in the admin console against the validation classname field.
There is also a generic validation implementation provided for jdbc 4.0 compliant drivers