*/
if( connection == null)
{
//logger.debug("Connection is null, get one from the pool");
try {
PGConnectionPoolDataSource source = (PGConnectionPoolDataSource)new InitialContext().lookup("TAMTDataSource");
connection = source.getConnection();
} catch(SQLException e) {
// log error
logger.debug("SQLException: " + e.getMessage());
} catch(NamingException e) {
// DataSource wasn't found in JNDI
logger.debug("JNDI naming exception: " + e.getMessage());
} finally {
//if(connection != null) {
// try {connection.close();}catch(SQLException e) {}
//}
}
} else {
try {
if( connection.isClosed())
{
try {
PGConnectionPoolDataSource source = (PGConnectionPoolDataSource)new InitialContext().lookup("TAMTDataSource");
connection = source.getConnection();
} catch(SQLException e) {
// log error
logger.debug("SQLException: " + e.getMessage());
} catch(NamingException e) {
// DataSource wasn't found in JNDI