Tomcat5.5的一个问题

第一天来公司上班的时候,竟然被配置WEB程序的问题搞了半天。郁闷至极。
上班也有一年了,连个基础的东西都搞不定,难怪被本人鄙视
在tomcat的/conf/server.xml中配置连接池。
插入以下代码
<ResourceParams name="jdbc/MySQLDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- Don't set this any higher than max_connections on your
MySQL server, usually this should be a 10 or a few 10's
of connections, not hundreds or thousands -->

<parameter>
<name>maxActive</name>
<value>30</value>
</parameter>

<!-- You don't want to many idle connections hanging around
if you can avoid it, only enough to soak up a spike in
the load -->

<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>

<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 5 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<!-- Don't use autoReconnect=true, it's going away eventually
and it's a crutch for older connection pools that couldn't
test connections. You need to decide if your application is
supposed to deal with SQLExceptions (hint, it should), and
how much of a performance penalty you're willing to pay
to ensure 'freshness' of the connection -->

<parameter>
<name>validationQuery</name>
<value>SELECT 1</value>
</parameter>

<!-- The most conservative approach is to test connections
before they're given to your application. For most applications
this is okay, the query used above is very small and takes
no real server resources to process, other than the time used
to traverse the network.

If you have a high-load application you'll need to rely on
something else. -->

<parameter>
<name>testOnBorrow</name>
<value>true</value>
</parameter>

<!-- Otherwise, or in addition to testOnBorrow, you can test
while connections are sitting idle -->

<parameter>
<name>testWhileIdle</name>
<value>true</value>
</parameter>

<!-- You have to set this value, otherwise even though
you've asked connections to be tested while idle,
the idle evicter thread will never run -->

<parameter>
<name>timeBetweenEvictionRunsMillis</name>
<value>10000</value>
</parameter>

<!-- Don't allow connections to hang out idle too long,
never longer than what wait_timeout is set to on the
server...A few minutes or even fraction of a minute
is sometimes okay here, it depends on your application
and how much spikey load it will see -->

<parameter>
<name>minEvictableIdleTimeMillis</name>
<value>20000</value>
</parameter>

<!-- Username and password used when connecting to MySQL -->

<parameter>
<name>username</name>
<value>root</value>
</parameter>

<parameter>
<name>password</name>
<value>sa</value>
</parameter>

<!-- Class name for the Connector/J driver -->

<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>

<!-- The JDBC connection url for connecting to MySQL, notice
that if you want to pass any other MySQL-specific parameters
you should pass them here in the URL, setting them using the
parameter tags above will have no effect, you will also
need to use & to separate parameter values as the
ampersand is a reserved character in XML -->

<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/xinhui</value>
</parameter>

</ResourceParams>
竟然报错!调了半天还是没出来,主管老是跑过来问,你的配好没有?
只能不好意思的答复到:还没有
最后将以上的代码改为
<Resource name="jdbc/MySQLDB" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" maxIdle="20" maxWait="5000" username="root" password="123456" url="jdbc:mysql://localhost:3306/xinhui" maxActive="100" removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"/>这下竟然成功了。在网上查了下相关的问题,没有很好的解答。
应该是tomcat版本的问题吧
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值