问题描述
我遇到了一个奇怪的生产问题.环境如下:
I'm facing a weird production problem. Environment is the following:
- JBOSS 4.0.2
- SQL Server 2005
- 驱动程序 JTDS 1.2.5
不时会出现以下场景.
SQL 命令执行失败
java.sql.SQLException: I/O Error: Read timed out
(我可以忍受,如果它每天发生两次左右)
(I can live with that, if it just happens twice a day or so)
但是从那一刻起,连接似乎被浪费了,而池无法识别它,因为我不断收到
But from that moment on the connection seems to be wasted without the pool recognizing it, as I continously receive
java.sql.SQLException: Invalid state, the Connection object is closed.
从那一刻起.唯一有帮助的是重新启动 JBOSS.尽管我有
from that moment on. The only thing that helps is restarting JBOSS. This occurs despite of the fact that I have
<check-valid-connection-sql>select getdate()</check-valid-connection-sql>
在我的数据源定义中设置.
set up in my Datasource definition.
我想知道我是否可以使用自定义的 ValidConnectionChecker,它要么重建连接本身,要么显式抛出异常来解决这个问题.也许有人有其他建议.
I was wondering if I can use a custom ValidConnectionChecker, that either rebuilds the connection itself, or explicitly throws a Exception to fix this. Maybe anyone has other suggestions.
这是我完整的 DS 定义.
Here is my complete DS definition.
<local-tx-datasource>
<jndi-name>MyDS</jndi-name>
<connection-url>jdbc:jtds:sqlserver://192.168.35.235:1433/MyDb;user=user1;password=pwd;appName=MyApp;loginTimeout=15;socketTimeout=120</connection-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<user-name>user1</user-name>
<password>pwd</password>
<min-pool-size>10</min-pool-size>
<max-pool-size>25</max-pool-size>
<blocking-timeout-millis>60000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
<check-valid-connection-sql>select getdate()</check-valid-connection-sql>
</local-tx-datasource>
需要任何帮助.
问候
推荐答案
尝试将您的驱动程序类行更改为net.sourceforge.jtds.jdbcx.JtdsDataSource.net.sourceforge.jtds.jdbc.Driver 没有实现 javax.sql.ConnectionPoolDataSource 接口.来源:http://jtds.sourceforge.net/faq.html#features
Try changing your driver class line tonet.sourceforge.jtds.jdbcx.JtdsDataSource.net.sourceforge.jtds.jdbc.Driver doesn't implement the javax.sql.ConnectionPoolDataSource interface.source:http://jtds.sourceforge.net/faq.html#features
这篇关于JTDS 和 JBOSS JDBC 连接池问题,有什么解决办法?也许是自定义的 ValidConnectionChecker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!