---
title: "Struts1\u3000连接池配置"
author: "=死神="
date: "2008-09-22T22:29:00Z"
tags: ["Apache", "JDBC", "MySQL", "Struts", "XML"]
slug: "struts1"
draft: false
lastmod: "2008-09-22T22:29:00Z"
id: 245658
url: "https://shen198623.iteye.com/blog/245658"
---

struts-config.xml配置

 

```
<data-sources>       
        <data-source key="postgre" type="org.apache.commons.dbcp.BasicDataSource">
              <set-property property="autoCommit" value="true"/>
              <set-property property="driverClassName" value="com.mysql.jdbc.Driver"/>
              <set-property property="url" value="jdbc:mysql://localhost:3306/nrsattacksolution"/>
              <set-property property="maxCount" value="10"/>
              <set-property property="minCount" value="1"/>
              <set-property property="username" value="root"/>
              <set-property property="password" value="root"/>
     </data-source>
</data-sources>
```

 控制台上却抛出了这样的异常

java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

 

则需要将commons-pool.jar和commons-dbcp-1.2.1.jar这两个包引入到工程之中

[http://www.apache.org/dist/commons/pool/commons-pool-current.zip](http://www.apache.org/dist/commons/pool/commons-pool-current.zip)

[http://archive.apache.org/dist/commons/dbcp/binaries/commons-dbcp-1.2.1.zip](http://archive.apache.org/dist/commons/dbcp/binaries/commons-dbcp-1.2.1.zip)