title: Akka: how to make non-blocking JDBC requests
body: <p>I am brand new to Akka (<strong>Java lib</strong>) and am trying to understand if Akka can be used to make non-blocking requests to JDBC, and if so, what that it would look like. I <em>believe</em> most JDBC drivers open a socket connection and block the thread that created it until a particular JDBC response is received, and so there might not be much Akka can do to help here, but I am wondering if there is a way (perhaps through Futures or Agents?) that Akka could help improve performance, and allow the actor system to continue processing data, while an existing JDBC call is being made and awaiting a response.</p>
  
  <p>I found <a href="http://noisycode.com/blog/2014/07/27/akka-and-jdbc-to-services/" rel="noreferrer">this article</a> which is a bit vague/cryptic, but it sounds like futures might be the key here. However that article doesn’t really show any meaningful (real-world) code examples, and so I’m still at a loss. So let’s say we have a stored procedure, <code>sp_make_expensive_calculation</code>, that normally takes 10 - 30 seconds to return a response and that is normally called via JDBC like so:</p>
  
  <pre><code>String makeExpensiveCalculationSql = "{call sp_make_expensive_calculation(?)}";
  callableStatement = dbConnection.prepareCall(makeExpensiveCalculationSql);
  callableStatement.setInt(1, 10);
  
  // Could take up to 30 seconds to complete.
  callableStatement.executeUpdate();
  
  int answer = callableStatement.getString(2);
  </code></pre>
  
  <p>Can Akka do anything to help here so that the actor system can continue processing data (and even make other <code>sp_make_expensive_calculation</code> calls) while we wait for the first call to return?</p>