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.
Thread_1 - abc() method called. connection opened and closed inside method.
Thread_2 - abc() method called. connection opened and closed inside method.
Thread_3 - abc() method called. connection opened and closed inside method.
I am not clear why the exception occurs even though connection opened and closed properly. DataBase - Ms sql, Java - 1.6, apache-tomcat 6.
The main thing is that it's not consistent, sometimes exception occurs and sometimes not.
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)
Please advise on this.