Tomcat 6 connection pool Configuration

Source: Internet
Author: User

Tomcat 6 is configured with the connection pool, but the Running always reports HTTP Status 500-javax. servlet. servletException: org. apache. tomcat. dbcp. dbcp. SQLNestedException: Cannot create JDBC driver of class ''for connect URL 'null' error. Check whether the URL is correct! After checking on the Internet, the configuration of Tomcat 6 is different from the previous one. It is better not to configure it in server. xml, but in context. xml. Is the context. xml file under the site directory, not under tomcat_home \ conf. Tomcat_home \ webapps \ yourApp \ META-INF \ context. xml, my website directory does not contain context. create one, so you can configure the connection pool separately on different websites without restarting Tomcat. Tomcat will be automatically reloaded. Running Environment: MyEclipse 6.5 context. xml example: <? Xml version = "1.0" encoding = "UTF-8"?> <Context reloadable = "true" crossContext = "true"> <! -- Default set of monitored resources --> <WatchedResource> WEB-INF/web. xml </WatchedResource> <! -- Uncomment this to disable session persistence resume SS Tomcat restarts --> <! -- <Manager pathname = ""/> --> <Resource name = "jdbc/ConnectionPool" auth = "Container" type = "javax. SQL. dataSource "maxActive =" 20 "maxIdle =" 5 "maxWait =" 10000 "username =" sa "password =" admin "url =" jdbc: sqlserver: // localhost: 1433; databaseName = db_net "driverClassName =" com. microsoft. jdbc. sqlserver. SQLServerDriver "/> </Context> After configuring the connection pool, try to delete the context. xml to the configuration file, while clearing the content in the work directory under the Tomcat directory, and then re-run it, the magic is still normal running ?? This configuration method automatically adds the above conext under the apache-tomcat-6.0.37 \ conf \ Catalina \ localhost directory after MyEclipse is deployed. the xml file is copied to it and renamed with the project's Web Context-root name. Therefore, the context is deleted. the xml file can still run normally. It is worth noting that the context is modified in MyEclipse. the xml file application will no longer modify the files in the apache-tomcat-6.0.37 \ conf \ Catalina \ localhost directory, that is, the modification is invalid. (I don't know if this is a problem with MyEclipse 6.5, or if this problem also occurs in other versions of MyEclipse). You can also use the global configuration method as the first step: configure the context under conf in tomcat. xml file, add the connection pool as follows: Xml Code <Resource name = "jdbc/ConnectionPool" auth = "Container" type = "javax. SQL. dataSource "maxActive =" 20 "maxIdle =" 5 "maxWait =" 10000 "username =" sa "password =" admin "url =" jdbc: sqlserver: // localhost: 1433; databaseName = db_net "driverClassName =" com. microsoft. jdbc. sqlserver. SQLServerDriver "/> </Context> Step 2: configure the web under your application. add between xml: <resource-ref> <description> SQL server text app </description> <res-ref-name> jdbc/ConnectionPool </res-ref-name> <res-type> javax. SQL. dataSource </res-type> <res-auth> Container </res-auth> </resource-ref>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.