title: Should JDBC Blob (not) be free()'d after use?
body: <p>Just whacking together an export from an old DB that contains binary data, I stumbled over an exception in one of our utility methods:</p>
  
  <blockquote>
    <p>java.lang.AbstractMethodError: net.sourceforge.jtds.jdbc.BlobImpl.free()</p>
  </blockquote>
  
  <p>After checking our codebase, I found that utility method was never used until now, bascially it looks like this:</p>
  
  <pre><code>public BinaryHolder getBinary(final int columnIndex) throws SQLException {
      Blob blob = null;
      try {
          blob = resultSet.getBlob(columnIndex);
          final BinaryHolder binary = BinaryHolderUtil.create(blob);
          return binary;
      } finally {
          if (blob != null)
              blob.free();
      }
  }
  </code></pre>
  
  <p>BinaryHolder is just a wrapper that holdes the binary data (and before you ask, the code executes fine until it reaches the finally clause - BinaryHolderUtil.create(blob) does <em>not</em> attempt to free the blob).</p>
  
  <p>Investigating further I found that everywhere else we access Blob's, the blob is just obtained using getBlob() and not free'd at all (The Javadoc says it will be automatically disposed of when the result set is closed).</p>
  
  <p>Question now: <em>Should</em> the blob be free()'d manually (after all the ResultSet may be held for more than just accessing the blob), and if yes <em>how</em> can it be free()'d in a way that works even with a driver that does not implement it?</p>
  
  <p>(We are using SQL-Server with JTDS1.25, if that wasn't already obvious from the exception)</p>