Custom Validation in GlassFish V3

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.


Turn on validation


Set to custom-validation


Set 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.


  • org.glassfish.api.jdbc.validation.DerbyConnectionValidation

  • org.glassfish.api.jdbc.validation.MySQLConnectionValidation

  • org.glassfish.api.jdbc.validation.PostgresConnectionValidation

  • org.glassfish.api.jdbc.validation.OracleConnectionValidation


There is also a generic validation implementation provided for jdbc 4.0 compliant drivers


  • org.glassfish.api.jdbc.validation.JDBC40ConnectionValidation

References

[1] Connection Validation in GlassFish

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

shalini_m

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today