title: Error while using connection pooling
body: <p>I am new to java. i have a java class which accesses the database through jdbc. In each method of this class, i am opening and closing the connection, which seems to be causing the performance hit. I have tried using the jdbc connection pooling but not sure how to proceed with the same. I have created a  Server.xml and Context.xml file as below.</p>
  
  <p>Server.xml</p>
  
  <pre><code>&lt;GlobalNamingResources&gt;
    &lt;Resource type="javax.sql.DataSource"
              name="jdbc/TestDB"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
              driverClassName="com.mysql.jdbc.Driver"
              url=""
              username=""
              password=""
  /&gt;
   &lt;/GlobalNamingResources&gt;
  </code></pre>
  
  <p>Context.xml</p>
  
  <pre><code>&lt;Context&gt;
    &lt;ResourceLink type="javax.sql.DataSource"
                  name="jdbc/LocalTestDB"
                  global="jdbc/TestDB"
  /&gt;
   &lt;/Context&gt;
  </code></pre>
  
  <p>and i have created a test java class as below.</p>
  
  <pre><code>import java.sql.Connection;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.sql.DataSource;
  
  public class TestDBConnections {
  
      Context initContext = new InitialContext();
      Context envContext = (Context) initContext.lookup("java:/comp/env");
      DataSource datasource = (DataSource) envContext.lookup("jdbc/LocalTestDB");
      Connection con = datasource.getConnection();
  
  }    
  </code></pre>
  
  <p>i am getting the below error :  </p>
  
  <blockquote>
    <p>Default constructor cannot handle exception type NamingException
    thrown by implicit super constructor. Must define an explicit
    constructor.</p>
  </blockquote>
  
  <p>Please help me with it.</p>