|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
在1995年5月23日以“Java”的名称正式发布了。办理|成绩某天在服务器上的网页打不开了,频仍报以下毛病。
2007-3-181:08:26org.apache.tomcat.util.threads.ThreadPoollogFull
严峻:Allthreads(150)arecurrentlybusy,waiting.IncreasemaxThreads(150)orchecktheservletstatus
在网上找了些回覆,以下是我以为准确的回覆:
1.我想你的部分资本没有开释,积存卡逝世的
2.毗连池成绩
3.应当是服务器端呼应request的线程的处置工夫太长招致的
剖析:
事先利用网站的人数只要2团体,不成能答到到了并发线程150的上线。以是应当不是数据库的成绩。
经由过程对堕落的提醒判别,应当是毗连池利用分歧理酿成的,大概基本没设置毗连池。和数据库毗连的部分是利用Spring的数据源JDBC连的,以下:
<beans>
<beanid="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!--driverforMySQL-->
<propertyname="driverClassName"><value>org.gjt.mm.mysql.Driver</value></property>
<propertyname="url"><value>jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8</value></property>
<propertyname="username"><value>test</value></property>
<propertyname="password"><value>test</value></property>
</beans>
成绩应当呈现在Spring的DriverManagerDataSource上,它卖力办理这些毗连的。
下边是对DriverManagerDataSource的注释
DriverManagerDataSourceinSpringFramework
javax.sqlInterfaceDataSource
ImplementationofSmartDataSourcethatconfiguresaplainoldJDBCDrivervia
beanproperties,andreturnsanewConnectioneverytime.
UsefulfortestorstandaloneenvironmentsoutsideofaJ2EEcontainer,either
asaDataSourcebeaninarespectiveApplicationContext,orinconjunctionwith
asimpleJNDIenvironment.Pool-assumingConnection.close()callswillsimply
closetheconnection,soanyDataSource-awarepersistencecodeshouldwork.
InaJ2EEcontainer,itisrecommendedtouseaJNDIDataSourceprovidedbythe
container.SuchaDataSourcecanbeexportedasaDataSourcebeaninan
ApplicationContextviaJndiObjectFactoryBean,forseamlessswitchingtoandfrom
alocalDataSourcebeanlikethisclass.
Ifyouneeda"real"connectionpooloutsideofaJ2EEcontainer,consider
ApachesJakartaCommonsDBCP.ItsBasicDataSourceisafullconnectionpool
bean,supportingthesamebasicpropertiesasthisclassplusspecificsettings.
Itcanbeusedasareplacementforaninstanceofthisclassjustbychanging
theclassnameofthebeandefinitionto
"org.apache.commons.dbcp.BasicDataSource".
-----------------------------------------------
ManyJakartaprojectssupportinteractionwitharelationaldatabase.Creatinga
newconnectionforeachusercanbetimeconsuming(oftenrequiringmultiple
secondsofclocktime),inordertoperformadatabasetransactionthatmight
takemilliseconds.Openingaconnectionperusercanbeunfeasibleina
publicly-hostedInternetapplicationwherethenumberofsimultaneoususerscan
beverylarge.Accordingly,developersoftenwishtosharea"pool"ofopen
connectionsbetweenalloftheapplicationscurrentusers.Thenumberofusers
actuallyperformingarequestatanygiventimeisusuallyaverysmall
percentageofthetotalnumberofactiveusers,andduringrequestprocessingis
theonlytimethatadatabaseconnectionisrequired.Theapplicationitself
logsintotheDBMS,andhandlesanyuseraccountissuesinternally.
ThereareseveralDatabaseConnectionPoolsalreadyavailable,bothwithin
Jakartaproductsandelsewhere.ThisCommonspackageprovidesanopportunityto
coordinatetheeffortsrequiredtocreateandmaintainanefficient,
feature-richpackageundertheASFlicense.
Thecommons-dbcppackagereliesoncodeinthecommons-poolpackagetoprovide
theunderlyingobjectpoolmechanismsthatitutilizes.
Applicationscanusethecommons-dbcpcomponentdirectlyorthroughtheexisting
interfaceoftheircontainer/supportingframework.ForexampletheTomcat
servletcontainerpresentsaDBCPDataSourceasaJNDIDatasource.James(Java
ApacheMailEnterpriseServer)hasintegratedDBCPintotheAvalonframework.A
Avalon-styledatasourceiscreatedbywrappingtheDBCPimplementation.The
poolinglogicofDBCPandtheconfigurationfoundinAvalonsexcaliburcodeis
whatwasneededtocreateanintegratedreliableDataSource.
看完懂得释,现实上是由于DriverManagerDataSource创建毗连是只需有毗连就新建一个connection,基本没有毗连池的感化。改成以下开源的毗连池会好点。
<beanid="myDataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">
<propertyname="driverClassName">
<value>org.hsqldb.jdbcDriver</value>
</property>
<propertyname="url">
<value>jdbc:hsqldb:hsql://localhost:9001</value>
</property>
<propertyname="username">
<value>sa</value>
</property>
<propertyname="password">
<value></value>
</property>
</bean>
测试经由过程,成绩打消,假如没有搜刮引擎找谜底不会这么快办理成绩。
没有那个大公司会傻了吧唧用.net开发大型项目,开发了,那等于自己一半的生命线被微软握着呢。而.net不行,限制在window系统,又是捆绑,鄙视微软之! |
|