title: How to Configure JNDI DataSource in Tomcat 8 with Java Configuration:
body: <p>How to Configure JNDI DataSource in Java Configuration File Instead of Following Code Snippet in "web.xml" Servlet Context:</p>
  
  <pre><code>&lt;resource-ref&gt;
     &lt;description&gt;DB Connection&lt;/description&gt;
     &lt;res-ref-name&gt;jdbc/DatabaseName&lt;/res-ref-name&gt;
     &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
     &lt;res-auth&gt;Container&lt;/res-auth&gt;
  &lt;/resource-ref&gt;
  </code></pre>