Tomcat数据库连接池配置如下:
server.xml 配置Resource :
<Resource name="jdbc/ExampleDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="APP" password="APP" driverClassName="org.apache.derby.jdbc.ClientDriver" url="jdbc:derby://localhost:1527/springside-example;create=true"/>
context.xml 文件增加:
<WatchedResource>WEB-INF/web.xml</WatchedResource> <ResourceLink name="jdbc/ExampleDB" global="jdbc/ExampleDB" type="javax.sql.DataSource"/>
Tomcat共享线程池配置:
取消Executor 注释,修改连接数至自己合适的数值既可。
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="200" minSpareThreads="100" maxIdleTime="60000"/>
executor="tomcatThreadPool" 标明此连接使用上面配置的名称为tomcatThreadPool 的连接池,无属性共享连接不会生效 protocol表示使用的是 http协议 端口号为8080
<Connector port="8080" protocol="HTTP/1.1" redirectPort="8443" connectionTimeout="20000" executor="tomcatThreadPool" acceptCount="100" useBodyEncodingForURI="true" enableLookups="false" />