平台默认的用的tomcat6的版本,升级为tomcat后需要要连接sqlserver数据库,并且已经参考升级tomcat8报错apache-tomcat\lib\jcifs.jar (系统找不到指定的文件。)中的说明替换了新的sqlserver驱动后,还会报如下的错误:

Caused by: java.lang.AbstractMethodError
        at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:924)
        at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:282)
        at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:364)
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2355)
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2338)
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2067)
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1543)
        at com.justep.system.data.Transaction.getConnectionWithJndi(Unknown Source)
        at com.justep.system.data.Transaction.getConnection(Unknown Source)
        at com.justep.system.data.Transaction.getConnection(Unknown Source)
        at com.justep.model.ModelUtils.getConnection(Unknown Source)

这个错误是tomcat的DBCP (数据库连接池) 使用的规范做了调整,tomcat 7及之前的版本用的是DBCP1,而tomcat 8 使用的是DBCP2 规范. 而DBCP2 中将测试数据库连接中的isValid()接口实现换成了validationQuery()
因此我们如果想在tomcat 8 中使用JTDS 就必须在Resource 加上一条 validationQuery=”select 1″,即在tomcat\conf\context.xml的数据源配置上加上validationQuery=”select 1″
如下:

<Resource name="demo" auth="Container" type="javax.sql.DataSource" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://mssql-2008.justep.com:1433/jstest" username="x5" password="x5" maxActive="10" maxIdle="5"  validationQuery="select 1"/>