Tomcat connection pooling, install jdbc driver for web-app

后端 未结 2 845
长情又很酷
长情又很酷 2021-01-03 11:41

I am making a web-app with Tomcat 6 as the container and I\'m trying to use connection pooling. The jdbc driver I am using is jtds-1.2.2.

2条回答
  •  天命终不由人
    2021-01-03 11:59

    To use Tomcat's connection pool, you must copy the JDBC Driver's jar into $CATALINA_HOME/lib (as documented) so that the driver class is visible through the Common class loader or DBCP won't be able to find it, hence the ClassNotFoundException. Tomcat's class loaders hierarchy is illustrated below:

          Bootstrap
              |
           System
              |
           Common
           /     \
      Webapp1   Webapp2 ... 
    

    And libraries from WEB-INF/lib are not visible from the Common class loader (which is a good thing).

    If you can't copy your driver into $CATALINA_HOME/lib, you won't be able to use Tomcat's connection pool. In that case, you'll have to use a standalone connection pool (and to bundle it along your driver in WEB-INF/lib). And I second BalusC here, I would use C3P0.

提交回复
热议问题