要是学习的话有现成的干吗不用哪?配置你可以参考struts的faq文档
This is how you would specify a DBCP BasicDataSource for your application: 
<data-sources>
<!-- configuration for commons BasicDataSource -->
<data-source type="org.apache.commons.dbcp.BasicDataSource">
    <set-property
      property="driverClassName"
      value="org.postgresql.Driver" />
    <set-property
      property="url"
      value="jdbc:postgresql://localhost/mydatabase" />
    <set-property
      property="username"
      value="me" />
    <set-property
      property="password"
      value="test" />
    <set-property
      property="maxActive"
      value="10" />
    <set-property
      property="maxWait"
      value="5000" />
    <set-property
      property="defaultAutoCommit"
      value="false" />
    <set-property
      property="defaultReadOnly"
      value="false" />
    <set-property
      property="validationQuery"
      value="SELECT COUNT(*) FROM et" />
</data-source>
</data-sources>Note that you can define as many datasource objects as your application requires and refer to each using a logical name. This can be useful in providing better security or scalability, or even to test datasource implementations against each other. After a DataSource is defined, here is an example of using the manager to establish a connection from within an Action's execute method. 
public ActionForward
       execute(ActionMapping mapping,
               ActionForm form,
               HttpServletRequest request,
               HttpServletResponse response) throws Exception
{
 javax.sql.DataSource dataSource;
 java.sql.Connection myConnection;
 try {
  dataSource = getDataSource(request);
  myConnection = dataSource.getConnection();
  // do what you wish with myConnection
 } catch (SQLException sqle) {
    getServlet().log("Connection.process", sqle);
 } finally {
    //enclose this in a finally block to make
    //sure the connection is closed
    try {
       myConnection.close();
    } catch (SQLException e) {
       getServlet().log("Connection.close", e);
    }
   }
}

解决方案 »

  1.   

    楼上的朋友,我想知道那个bean在哪里。我的struts里面好像没有呢。
      

  2.   

    《Struts下拉框的实现》
    《如何实现Struts 数据库应用程序》
    《如何在Struts 数据库应用程序中实现分页显示》
    《如何在Struts 数据库应用程序中实现记录的删除、更新及链接》
    《如何在Struts 数据库应用程序中实现记录的添加》
    《如何建立一个带登陆页面的Struts数据库应用程序》
    《如何建立一个带登陆页面及角色的Struts数据库应用程序》上述这些Struts数据库应用文章在下面的网站上有:
    __________________________________
    http://dev.csdn.net/user/kui
    http://javaweb.51.net/
    http://javawebStudio.51.net/
    http://javaweb.getbbs.com/下载《Struts开发实例》地址:
    http://www.infoxa.com/asp/book/xxnr.asp?id=1333
      

  3.   

    是tomcat自带的
    在tomcat_home/common/lib/commons-dbcp-1.1.jar下面