What you mean by 'global variable'?
If you 'close' a connection from application side it is only marked that it can be returned to the pool.
If you left open ResultSets or Statements it will be also end in a DB-cursor leak (except you set the tracking in the DS file :) )
So you have to reset your variables yourself, or you might add a SQL comand that 'check' the connection getting from pool.
See http://community.jboss.org/wiki/configdatasources for this.