我在用tomcat 5.5.16 + jdk1.5.0_06 + struts 1.2.9在winXP上进行java web应用的开发,其中用到了连接池,我按照网上的做法首先在server.xml当中进行连接池的配置,没有错误。之后,好多文章都说还需要在web.xml当中进行相应的配置,大致如下:
  <resource-ref>
    <description>WebForum data source.</description>
    <res-ref-name>jdbc/WebForumDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
可是由于我的粗心,我忘记了配置web.xml,但是意外的是我的web程序仍然可以正常的运行,数据库的操作依然很正常,所以我有些糊涂,不知道这是不是tomcat版本的差异,不知道大家有没有遇到这种情况。谢谢。

解决方案 »

  1.   

    刚学到的,5.5以上版本可以直接在context.xml中配置 <Resource name="jdbc/test" 
      type="javax.sql.DataSource"
      password="123"
      driverClassName="com.mysql.jdbc.Driver"
      maxIdle="2"
      maxWait="5000"
      username="root"
      url="jdbc:mysql://localhost:3306/test"
      maxActive="4"/>
      

  2.   

    to ericbu(Make a difference!) :
    对不起,今天才看到回复,你的意思是说5.5版本以上的就不用在像以前那样需要在web.xml当中设置了,对吗?谢谢。
      

  3.   

    是的,我只是在context.xml中配置,是可以成功的,你试一下
      

  4.   

    to ericbu:
    非常感谢你的回复。