title: If i create a Spring datasource, do i still need to define the datasource inside Tomcat context.xml?
body: <p>currently we have an application that is configured by using a datasource inside a Tomcat context.xml file. So we are able to succesfully get a connection by retrieving the JNDI name and get a connection. I was wondering if we could replace this by using a Spring datasource and if we still need the information inside the context.xml file?</p>
  
  <p>Example 'context.xml':</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Context&gt;
      &lt;Resource
          name="jdbc/myDataSource"
          auth="Container"
          type="javax.sql.DataSource"
          username="john"
          password="doe"
          driverClassName="&lt;removed&gt;"
          url="&lt;removed&gt;"
          maxActive="30"
          maxIdle="10"
          maxWait="1000"
          removeAbandonedTimeout="60"
          removeAbandoned="true"
          logAbandoned="true"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>So in our code we search for a JNDI context like this:</p>
  
  <pre><code>Context envCtx = (Context) initCtx.lookup(..);
  DataSource ds = (DataSource) envCtx.lookup(..);
  Connection connection = ds.getConnection();
  </code></pre>
  
  <p>I was wondering if we could better define a Spring Datasource instead of using this approach and how we could do this?</p>