Menu

how to enable tracing in the jtds jdbc driver

Help
2009-08-06
2012-08-15
  • Albert Tong-Schmidt

    Our Web application is running within Tomcat is using jtds 1.2.2 and is experiencing the following exception:

    java.sql.SQLException: Invalid state, the Connection object is closed.
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1494)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:2177)
    at com.inquira.content.ContentStoreImpl.getPreparedStatement(ContentStoreImpl.java:4246)
    at com.inquira.content.ContentStoreImpl.getDocumentData(ContentStoreImpl.java:2326)
    at com.inquira.content.Document.getContent(Document.java:1079)

    We verified there were no network outages and the DBA confirmed the MSSQLServer DB was not terminating the connection.

    I need debug level proof from the driver side to confirm whether there are issues with our code. Any information on how to turn on debug tracing with jtds would be appreciated.

    Thanks,

    ats2228

     
    • Albert Tong-Schmidt

      That's what I thought. I hoping there were options to turn on tracing, but it looks like I'll need to work with the developer to instrument the code. Thanks for the info.

      ats2228

       
    • momo

      momo - 2009-08-07

      I don't know what kind of tracing you expect, but what jTDS provides will most likely not help you with your problem. I'd suggest you modify the jTDS source code yourself. All you'll probably need is to modify 3 methods of class net.sourceforge.jtds.jdbc.ConnectionJDBC2:

      1. in method close() create an Exception and store it to some instance variable
      2. in method setClosed() create an Exception and store it to the instance variable
      3. in method checkOpen() print a stacktrace of the stored exception before throwing the SQLException

      This way you may find out why the connections is closed.

      Nevertheless, to answer your question:
      Of course jTDS supports the JDBC standard logging mechanisms (enabled via DriverManager.setLogWriter() or DataSource.setLogWriter()). Furthermore, you can simply call Logger.setActive() to log to a file "log.out";

      Hope that helps,
      momo

       

Log in to post a comment.