title: Getting TDS driver - java.lang.NullPointerException. this exception is not consistent
body: <p>I am getting exception when a method is called from 3 or 4 threads. This method get a DataBase connection inside method and populate some values from DB and then connection (connection, resultset and prepareStatement) getting closed properly inside method only. Still getting exception.</p>
  
  <p>Thread_1 - abc() method called. connection opened and closed inside method.<br>
  Thread_2 - abc() method called. connection opened and closed inside method.<br>
  Thread_3 - abc() method called. connection opened and closed inside method.<br></p>
  
  <p>I am not clear why the exception occurs even though connection opened and closed properly.
  DataBase - Ms sql,
  Java - 1.6, apache-tomcat 6.</p>
  
  <p><em>The main thing is that it's not consistent, sometimes exception occurs and sometimes not.</em></p>
  
  <pre><code>1. Exception -
  com.inet.tds.am: 
  [TDS Driver]java.lang.NullPointerException                                                                                                                                                
          at com.inet.tds.aj.a(Unknown Source)                                                                                                                                                               
          at com.inet.tds.r.g(Unknown Source)                                                                                                                                                                
          at com.inet.tds.r.executeQuery(Unknown Source)                                                                                                                                                     
          at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
  
  
  2. Exception -
  java.sql.SQLException: Connection is closed.                                                                                                                                                               
          at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:175)                                                                                  
          at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:301)
  </code></pre>
  
  <p>Please advise on this.</p>