本文介绍了JTDS和JBOSS JDBC连接池问题,有什么解决方案吗?也许是自定义的ValidConnectionChecker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临着一个奇怪的生产问题.环境如下:

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,它要么重建连接本身,要么显式抛出Exception来解决此问题.也许有人有其他建议.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 02:52
查看更多