com.evolveum.midpoint.repo.sql.util
Class MidPointConnectionTester

java.lang.Object
  extended by com.mchange.v2.c3p0.AbstractConnectionTester
      extended by com.mchange.v2.c3p0.impl.DefaultConnectionTester
          extended by com.evolveum.midpoint.repo.sql.util.MidPointConnectionTester
All Implemented Interfaces:
com.mchange.v2.c3p0.ConnectionTester, com.mchange.v2.c3p0.FullQueryConnectionTester, com.mchange.v2.c3p0.QueryConnectionTester, com.mchange.v2.c3p0.UnifiedConnectionTester, Serializable

public class MidPointConnectionTester
extends com.mchange.v2.c3p0.impl.DefaultConnectionTester

When getting serialization-related SQLException (as when getting any exception), c3p0 checks the connection whether it is valid. However, in case of PostgreSQL, ANY 'select' command used for testing (including 'select 1') fails in this situation with a message "current transaction is aborted, commands ignored until end of transaction block". So the connection is released, and new one is created, which leads to performance problems. So it is probably best to roll the transaction back before checking the connection validity. To be safe, we currently do this only for PostgreSQL; other databases (H2, MySQL) do not seem to have problems of this kind: - MySQL does not even notice any serialization issues (why??? that's a bit suspicious) - H2 checks the connection, but it can do that without problems within current transaction.

Author:
mederly
See Also:
Serialized Form

Field Summary
static String POSTGRESQL_PRODUCT_NAME
           
 
Fields inherited from interface com.mchange.v2.c3p0.UnifiedConnectionTester
CONNECTION_IS_INVALID, CONNECTION_IS_OKAY, DATABASE_IS_INVALID
 
Constructor Summary
MidPointConnectionTester()
           
 
Method Summary
 int activeCheckConnection(Connection c, String query, Throwable[] rootCauseOutParamHolder)
           
 int statusOnException(Connection c, Throwable t, String query, Throwable[] rootCauseOutParamHolder)
           
 
Methods inherited from class com.mchange.v2.c3p0.impl.DefaultConnectionTester
equals, hashCode
 
Methods inherited from class com.mchange.v2.c3p0.AbstractConnectionTester
activeCheckConnection, activeCheckConnection, activeCheckConnection, statusOnException, statusOnException, statusOnException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTGRESQL_PRODUCT_NAME

public static final String POSTGRESQL_PRODUCT_NAME
See Also:
Constant Field Values
Constructor Detail

MidPointConnectionTester

public MidPointConnectionTester()
Method Detail

activeCheckConnection

public int activeCheckConnection(Connection c,
                                 String query,
                                 Throwable[] rootCauseOutParamHolder)
Specified by:
activeCheckConnection in interface com.mchange.v2.c3p0.UnifiedConnectionTester
Overrides:
activeCheckConnection in class com.mchange.v2.c3p0.impl.DefaultConnectionTester

statusOnException

public int statusOnException(Connection c,
                             Throwable t,
                             String query,
                             Throwable[] rootCauseOutParamHolder)
Specified by:
statusOnException in interface com.mchange.v2.c3p0.UnifiedConnectionTester
Overrides:
statusOnException in class com.mchange.v2.c3p0.impl.DefaultConnectionTester


Copyright © 2013 evolveum. All Rights Reserved.