title: Java DataSource SessionFactory
body: <p>I'm confused about the difference between <code>DataSource</code> and <code>SessionFactory</code>.</p>
  
  <p>I think <code>SessionFactory</code> is a manager for retrieve Sessions (which are in fact connections to a database I guess). </p>
  
  <p><code>DataSource</code> has the method <code>getConnection()</code></p>
  
  <blockquote>
    <p>"Attempts to establish a connection with the data source that this DataSource object represents."</p>
  </blockquote>
  
  <p>It means a <code>DataSource</code> object always works directly with the database? </p>
  
  <p>If I have a pool of connections, <code>DataSource</code> will ask to the pool for a connection? Or will it try to get another connection to the database.</p>
  
  <p>Are in fact <code>DataSource</code> and <code>SessionFactory</code> the same? Both try to give sessions/connections?</p>