title: Tomcat and JDBC connection pooling
body: <p>I am trying to set up connection pooling to mysql databe with tomcat. My simple app is called Projekt, in my Projekt.xml in Apache/conf/Catalina/localhost I have</p>
  
  <pre><code>&lt;Context docBase="Projekt.war" path="/Projekt"&gt;
    &lt;Resource name="jdbc/mysqldb"
        auth="Container"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
        type="javax.sql.DataSource"
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/Music"
        username="andrzej"
        password="qazxsw"
        maxActive="20"
        maxIdle="30"
        maxWait="5"
    /&gt;
  &lt;/Context&gt; 
  </code></pre>
  
  <p>web.xml of my app</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;HelloServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.jtp.HelloServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;HelloServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/Hai&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;resource-ref&gt;     
          &lt;description&gt;DB Connection&lt;/description&gt;     
         &lt;res-ref-name&gt;jdbc/mysqldb&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>
  
  <p>and in my Apache/lib folder I have </p>
  
  <pre><code>mysql-connector-java-5.1.18-bin.jar
  </code></pre>
  
  <p>but when I execute this code:</p>
  
  <pre><code>Context initContext  = new InitialContext();
  dataSource = (DataSource)initContext.lookup("java:comp/env/jdbc/mysqldb");
  System.out.println(dataSource.getConnection().createStatement().
              execute("select * from Users"));
  </code></pre>
  
  <p>I get exception </p>
  
  <pre><code>org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
  </code></pre>
  
  <p>I am puzzled now, in some places I read that it may be caused by not placing driver in tomcat/lib, but I have it and it works, because when I tested the driver with manual connections it worked.</p>
  
  <p>For my setup I was trying to follow
  <a href="http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html" rel="noreferrer">http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html</a></p>
  
  <p>EDIT:
  Finally got it working, it seemed that I had some left context tags in one of the files so when parsing he overriden other attributes, so it is all my fault at the end.</p>