title: How to close JNDI connection?
body: <p>I am using JNDI for database connection. I have created a XML file in META-INF for connection.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- The contents of this file will be loaded for each web application --&gt;
  &lt;Context crossContext="true"&gt;
  
      &lt;!-- Default set of monitored resources --&gt;
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
  
      &lt;Resource name="jdbc/myDB" auth="Container"
          type="javax.sql.DataSource"
          maxActive="100" maxIdle="30" maxWait="600000"
          username="root" 
          password="abc123" 
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/game"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>In java class I am using following code to get the connection</p>
  
  <pre class="lang-java prettyprint-override"><code>    Context envContext;
      Datasource ds;
      envContext = new InitialContext();
      Context initContext  = (Context)envContext.lookup("java:/comp/env");
      DataSource ds = (DataSource)initContext.lookup("jdbc/myDB");
      Connection con=ds.getConnection();
  </code></pre>
  
  <p>But, how can i close the connection?</p>