@ -154,14 +154,28 @@ public abstract class DataSourceUtils {
@@ -154,14 +154,28 @@ public abstract class DataSourceUtils {
}
con . setReadOnly ( true ) ;
}
catch ( Throwable ex ) {
if ( ex instanceof SQLException & & ( ex . getClass ( ) . getSimpleName ( ) . contains ( "Timeout" ) | |
( ex . getCause ( ) ! = null & & ex . getCause ( ) . getClass ( ) . getSimpleName ( ) . contains ( "Timeout" ) ) ) ) {
// Assume it's a connection timeout that would otherwise get lost: e.g. from C3P0.
throw ( SQLException ) ex ;
catch ( SQLException ex ) {
Throwable exToCheck = ex ;
while ( exToCheck ! = null ) {
if ( exToCheck . getClass ( ) . getSimpleName ( ) . contains ( "Timeout" ) ) {
// Assume it's a connection timeout that would otherwise get lost: e.g. from JDBC 4.0
throw ex ;
}
exToCheck = exToCheck . getCause ( ) ;
}
// "read-only not supported" SQLException or UnsupportedOperationException
// -> ignore, it's just a hint anyway.
// "read-only not supported" SQLException -> ignore, it's just a hint anyway
logger . debug ( "Could not set JDBC Connection read-only" , ex ) ;
}
catch ( RuntimeException ex ) {
Throwable exToCheck = ex ;
while ( exToCheck ! = null ) {
if ( exToCheck . getClass ( ) . getSimpleName ( ) . contains ( "Timeout" ) ) {
// Assume it's a connection timeout that would otherwise get lost: e.g. from Hibernate
throw ex ;
}
exToCheck = exToCheck . getCause ( ) ;
}
// "read-only not supported" UnsupportedOperationException -> ignore, it's just a hint anyway
logger . debug ( "Could not set JDBC Connection read-only" , ex ) ;
}
}