Menu

IsValid() method and Tomcat 8 / DBCP 2.

2014-08-04
2014-08-21
  • Ognjen Blagojevic

    I am developing a webapp that uses jTDS to connect to MS SQL Server. I tried to migrate my webapp from Tomcat 7 to recently released Tomcat 8.0.9. Tomcat 8 uses DBCP 2.

    Unlike DBCP 1.x, DBCP 2 will call java.sql.Connection.isValid(int) when parameter validationQuery is not set. JTDS doesn't implement isValid method, so jTDS driver won't work with DBCP 2 or Tomcat 8, when validationQuery is not set, which is default. It will throw java.lang.AbstractMethodError.

    To workaround, one should just add validationQuery parameter (e.g. validationQuery = "select 1").

    Could you add support for isValid method to make the driver work with Tomcat 8 and DBCP 2, even when validationQuery is not set?

    -Ognjen

     
    • SiegeLion

      SiegeLion - 2014-08-15

      Wow..I finally found out what was wrong, do you care to elaborate on the validationQuery = "select 1" part?

      Where should i put it.. in the META-INF/Context.xml?

       
  • Ognjen Blagojevic

    Right, you shoud put it into <resource> tag for connection pool, which is usually in META-INF/context.xml:</resource>

    <Resource ... validationQuery="select 1" />
    

    -Ognjen

     

Log in to post a comment.

MongoDB Logo MongoDB