某天在服务器上的网页打不开了,频繁报以下错误。
2007-3-18 1:08:26 org.apache.tomcat.util.threads.ThreadPool logFull
严重: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status
在网上找了些回答,以下是我觉得正确的回答:
1.我想你的部分资源没有释放,积压卡死的
2.连接池问题
3.应该是服务器端响应request的线程的处理时间过长导致的
分析:
当时使用网站的人数只有2个人,不可能答到到了并发线程150的上线。所以应该不是数据库的问题。
通过对出错的提示判断,应该是连接池使用不合理造成的,或者根本没设置连接池。和数据库连接的部分是使用Spring的数据源JDBC连的,如下:
<beans>
<bean id= "dataSource " class= "org.springframework.jdbc.datasource.DriverManagerDataSource ">
<!-- driver for MySQL-->
<property name= "driverClassName "> <value> org.gjt.mm.mysql.Driver </value> </property>
<property name= "url "> <value> jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8 </value> </property>
<property name= "username "> <value> test </value> </property>
<property name= "password "> <value> test </value> </property>
</beans>
问题应该出现在Spring的DriverManagerDataSource上,它负责管理这些连接的。
下边是对DriverManagerDataSource 的解释
DriverManagerDataSource in Spring Framework
javax.sql Interface DataSource
Implementation of SmartDataSource that configures a plain old JDBC Driver via
bean properties, and returns a new Connection every time.
Useful for test or standalone environments outside of a J2EE container, either
as a DataSource bean in a respective ApplicationContext, or in conjunction with
a simple JNDI environment. Pool-assuming Connection.close() calls will simply
close the connection, so any DataSource-aware persistence code should work.
In a J2EE container, it is recommended to use a JNDI DataSource provided by the
container. Such a DataSource can be exported as a DataSource bean in an
ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from
a local DataSource bean like this class.
If you need a "real " connection pool outside of a J2EE container, consider
Apache 's Jakarta Commons DBCP. Its BasicDataSource is a full connection pool