jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MARTINEZ Antonio" <Antonio.Marti...@alcatel-lucent.com>
Subject Close SQL connection
Date Fri, 12 Sep 2008 02:07:05 GMT
Hello,

I'm using JackRabbit with Jboss with transaction.

>From my test, I need to close the SQL connection in the finally block of
the transaction, otherwise run out of SQL connection.

I was wondering if there is a cleaner way of closing the connection
without doing it in the code

Thanks,
Antonio


PD: This is the code
...
import java.sql.Connection;
...
            m_txTemplate.execute(new TransactionCallback() { 
                     public Object doInTransaction(TransactionStatus st)
{ 

                         Connection connection =
m_sessionFactory.getCurrentSession().connection(); 

                         try { 
                             execute(new SessionTemplate<Void>() { 
                                 public Void execute(Session session,
Node root) throws RepositoryException { 
                                     
                                     try { 
                                         // DO SOME MODIFICATION
                                         // CALL save

                                     return null; 
                                 } 
                             }); 
                             return 0; 
                         } catch (Exception e) { return Double.NaN; 
                         } finally { 
                             try { 

                                connection.close(); 

                             } catch (SQLException e) { } 
                         } 
                     } 
                 });                     
    

Mime
View raw message