Tomcat Connection Pool Setup

Discussions

General J2EE: Tomcat Connection Pool Setup

  1. Tomcat Connection Pool Setup (2 messages)

    I am wondering if anyone has successfully got Postgres + Tomcat + DBCP to work together - any instructions ???

    I spent most of the day just trying to get the connection pool to work using the jakarta docs - but I get the error below.

    I have the latest version of Postgres installed and running.
    And I have put the jars in the right place.

    Any help would be good.


    javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
    org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
    org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
    org.apache.jsp.test_jsp._jspx_meth_sql_query_0(org.apache.jsp.test_jsp:100)
    org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:58)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    Threaded Messages (2)

  2. As far as I can tell, you seem to have badly configured your driver classname and your connection url. Please post your server.xml file, so we can see if it is correctly configured as well as a listing of your TOMCAT_HOME/common/lib dir.

    My config is:
    <Server...>
    ...
      <GlobalNamingResources>
    ...
        <Resource name="jdbc/foo" scope="Shareable" type="javax.sql.DataSource"/>

        <ResourceParams name="jdbc/foo">
          <parameter>
            <name>url</name>
            <value>jdbc:mysql://localhost/foo</value>
          </parameter>
          <parameter>
            <name>validationQuery</name>
            <value>SELECT &apos;1&apos;</value>
          </parameter>
          <parameter>
            <name>maxIdle</name>
            <value>200</value>
          </parameter>
          <parameter>
            <name>maxActive</name>
            <value>10</value>
          </parameter>
          <parameter>
            <name>driverClassName</name>
            <value>com.mysql.jdbc.Driver</value>
          </parameter>
          <parameter>
            <name>maxWait</name>
            <value>5000</value>
          </parameter>
          <parameter>
            <name>removeAbandoned</name>
            <value>true</value>
          </parameter>
          <parameter>
            <name>testWhileIdle</name>
            <value>true</value>
          </parameter>
          <parameter>
            <name>minEvictableIdleTimeMillis</name>
            <value>4000</value>
          </parameter>
          <parameter>
            <name>username</name>
            <value>username</value>
          </parameter>
          <parameter>
            <name>logAbandoned</name>
            <value>true</value>
          </parameter>
          <parameter>
            <name>timeBetweenEvictionRunsMillis</name>
            <value>15000</value>
          </parameter>
          <parameter>
            <name>password</name>
            <value>foo</value>
          </parameter>
        </ResourceParams>
      </GlobalNamingResources>
      <Service ...>
            <Context className="org.apache.catalina.core.StandardContext" cachingAllowed="true" charsetMapperClass="org.apache.catalina.util.CharsetMapper" cookies="true" crossContext="true" debug="0" docBase="/opt/foo/src/webapp" mapperClass="org.apache.catalina.core.StandardContextMapper" path="/foo" privileged="false" reloadable="false" swallowOutput="false" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper">
              <ResourceLink global="jdbc/foo" name="jdbc/foo" type="javax.sql.DataSource"/>
            </Context>
      </Service>
    </Server>

    My common/lib dir contains:
    $ ls /usr/local/tomcat/common/lib/
    ... mysql-connector-java-3.0.15-ga-bin.jar ...

    HTH,
    sv
  3. tomcat pooling[ Go to top ]

    pls. see if tomcat <a href="connection" rel="nofollow">http://www.javaexperience.com/connection-pooling-in-tomcat/">connection pooling</a> and alternatives helps you