title: Should the connection be closed after each query in a long time transaction?
body: <p>We are currently dealing with the function, that has to work partially with the database, and partially with a service, whice operations are time-consuming. So, generally speaking, here is a transactional method, that has a code like this:</p>
  
  <pre><code>Connection conn = null;
  try {
    conn = getConnection(); // This I get from the connection pool
    Employee emp = queryDatabase(id); 
    // Point A - ??
    Response resp = makeLongTimeServiceCall(emp);
    // Point B - ??
    anotherQueryDatabase(resp);
  
  } catch (Exception e) {
    throw e; // And this also rolls back the transaction
  } finally {
    // If conn is not closed, close it, so there would be no leaks
  }
  </code></pre>
  
  <p>So the big question is - should I close the connection at point A and then get it again from the connection pool at point B, so that other servlets could use that connection while I interact with the service? My guess is that I should, but will this hurt my transaction?</p>