title: Create Datasource in Code or get it via JNDI from Application Server
body: <p>In a java application, If we want to use <code>javax.sql.DataSource</code> instead of <code>java.sql.DriverManager</code> to get connections, which approach would be better to create <code>DataSource</code> and WHY?</p>
  
  <ul>
  <li>Create <code>DataSource</code> in the application itself at the application startup time</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>Configure <code>DataSource</code> in the application server and get it via <code>JNDI</code></li>
  </ul>