instead of checking the closing of connection,make your that the code which deals with the connection , is kept in try block and in the finally block close the connections,especially check the transction part , whether you have ended the transaction or not.