MCPcopy Index your code
hub / github.com/apache/groovy / cacheConnection

Method cacheConnection

subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java:4056–4071  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

createConnectionMethod · 0.95
closeResourcesMethod · 0.95

Tested by

no test coverage detected