SQL Server 2000 Driver for JDBC: Connection reset

SQL Server 2000 Driver for JDBC: Connection reset by peer

If you’re using the SQL Server 2000 Driver for JDBC and Commons DBCP and you either you see this error in your logs:

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer: socket write error

and / or your application stops functioning after your SQL Server is restarted or the connection between the your application and the SQL Server is terminated, then you need to add this to your JDNI setup:

<parameter>
  <name>validationQuery</name>
  <value>select $somecolumn FROM $sometable</value>
</parameter>

 


where the value is a query that returns at least one row from your database. According to the documentation , the validation query is:

“… invoked in an implementation-specific fashion to determine if an instance is still valid to be returned by the pool. It will only be invoked on an “activated” instance.”

In my testing, if I add the validationQuery parameter to my JNDI setup, restart the servlet container (in this case Tomcat), request a page and then stop SQL Server, an error is returned (as expected). After starting SQL Server and requesting another page, the application returns to normal usage (which doesn’t happen if the validationQuery parameter is not present).

 

转自:http://cephas.net/blog/2004/07/14/sql-server-2000-driver-for-jdbc-connection-reset-by-peer/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值