title: Why use DataSource instead of XADataSource?
body: <p>As far as I understand there are two types of <code>DataSource</code> connections, <code>javax.sql.DataSource</code> and <code>javax.sql.XADataSource</code>, <a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/sqldatasources.html" rel="noreferrer">this tutorial</a> explains that <code>javax.sql.DataSource</code> give the connection the ability to be pooled and <code>javax.sql.XADataSource</code> give the connection distributed transactional behavior.</p>
  
  <p>I understand most <code>XADataSource</code> will implement connection pooling as well as distributed transactions so I don't see the point to use a <code>DataSource</code> when you could use a <code>XADataSource</code> and have both.</p>
  
  <p>Are there any tradeoff when choosing a <code>XADataSource</code> over a <code>DataSource</code>?</p>
  
  <p>I understand is not mandatory for a <code>XADataSource</code> to use pooled connections, is it there a way to find out if a <code>XADataSource</code> uses pooled connections or only relying on the <code>XADataSource</code> provider's documentation?</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I am refering to <code>javax.sql.DataSource</code> and <code>javax.sql.XADataSource</code> because those are the <a href="https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Attributes" rel="noreferrer">types <code>Tomcat 8</code> factory gives you</a>:</p>
  
  <blockquote>
    <p>Type should always be <strong>javax.sql.DataSource</strong> or <strong>javax.sql.XADataSource</strong></p>
    
    <p>Depending on the type a org.apache.tomcat.jdbc.pool.DataSource or a
    org.apache.tomcat.jdbc.pool.XADataSource will be created.</p>
  </blockquote>
  
  <p>I do understand that in the end I would be using a <code>DataSource</code> on my code as an API, abstracting the underlying implementation... my question is more related on the decision making process I have to go through when I am configuring <code>Tomcat 8</code> (or any other server as well).</p>
  
  <p>I want to have pooled connections and there are many <code>XADataSource</code> implementations that will give transactional and pooled connections, so why not always use <code>XADataSource</code> if I will get more? (this of course doesn't applies for a <code>XADataSource</code> that doesn't implements pooled connections)</p>