There are several Database Connection Pools already available, both within Jakarta products and elsewhere. This Commons package provides an opportunity to coordinate the efforts required to create and maintain an efficient, feature-rich package under the ASF license. The commons-dbcp package relies on code in the commons-pool package to provide the underlying object pool mechanisms that it utilizes. Applications can use the commons-dbcp component directly or through the existing interface of their container / supporting framework. For example the Tomcat servlet container presents a DBCP DataSource as a JNDI Datasource. James (Java Apache Mail Enterprise Server) has integrated DBCP into the Avalon framework. A Avalon-style datasource is created by wrapping the DBCP implementation. The pooling logic of DBCP and the configuration found in Avalon's excalibur code is what was needed to create an integrated reliable DataSource. 看完了解释,事实上是因为DriverManagerDataSource建立连接是只要有连接就新建一个connection,根本没有连接池的作用。改为以下开源的连接池会好点。 <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>org.hsqldb.jdbcDriver</value> </property> <property name="url"> <value>jdbc:hsqldb:hsql://localhost:9001</value> </property> <property name="username"> <value>sa</value> </property> <property name="password"> <value></value> </property> </bean> 测试通过,问题消除,如果没有搜索引擎找答案不会这么快解决问题。 |