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