Caches the connection used while the closure is active. If the closure takes a single argument, it will be called with the connection, otherwise it will be called with no arguments. @param closure the given closure @throws SQLException if a database error occurs
(@ClosureParams(value=SimpleType.class, options="java.sql.Connection") Closure closure)
| 4054 | * @throws SQLException if a database error occurs |
| 4055 | */ |
| 4056 | public void cacheConnection(@ClosureParams(value=SimpleType.class, options="java.sql.Connection") Closure closure) throws SQLException { |
| 4057 | boolean savedCacheConnection = cacheConnection; |
| 4058 | cacheConnection = true; |
| 4059 | Connection connection = null; |
| 4060 | try { |
| 4061 | connection = createConnection(); |
| 4062 | callClosurePossiblyWithConnection(closure, connection); |
| 4063 | } finally { |
| 4064 | cacheConnection = false; |
| 4065 | closeResources(connection, null); |
| 4066 | cacheConnection = savedCacheConnection; |
| 4067 | if (dataSource != null && !cacheConnection) { |
| 4068 | useConnection = null; |
| 4069 | } |
| 4070 | } |
| 4071 | } |
| 4072 | |
| 4073 | /** |
| 4074 | * Performs the closure within a transaction using a cached connection. |
nothing calls this directly
no test coverage detected