openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: EntityManager dosn't release connection in XA transactions
Date Wed, 23 Dec 2009 06:35:08 GMT

The code does not show when/where the connections are released ... neither
the method that uses native SQL nor the method that uses EntityManager (for
which the app server should manage connection reuse/pooling). 
Are you sure it is not the native SQL method that is leaking the
connections?



is_maximum wrote:
> 
> FYI, we have monitored our connection pool, when using DataSource the
> NumConnDestroyed is increased after each statement execution but using
> EntityManager the NumConnDestroyed is always 0 
> 
> here is the snippet code and more details:
> 
> 
> Datasource Classname: oracle.jdbc.xa.client.OracleXADataSource
> Resource Type: javax.sql.XADataSource
> 
> Oracle Version: 10.2.0.1.0
> Oracle JDBC Driver Version: 10.2.0.1.0
> Glassfish: 9.1_02 (build b04-fcs)
> OpenJPA: 1.2.1
> 
> 
> @Resource(name="jdbc/myDS", type=javax.sql.DataSource.class)
> private DataSource dataSource;
> 
> @WebMethod(operationName="addAccount")
>       @TransactionAttribute(TransactionAttributeType.REQUIRED)
>       public String addAccount(){
>             String accountCode;
>             String sql = "INSERT INTO ACCOUNT …";
>             Connection connection = null;
>             Statement statement = null;
>             try{
>                   
>                   connection = dataSource.getConnection();
>                   
>                   statement = connection.createStatement();
>                   statement.executeUpdate(sql);
>                   
>                   
>             }catch(SQLException exception){
>                   //…
>             }
>             
> return accountCode;
>       }
> 
>       
> @PersistenceContext(unitName="pu-cm")
>       protected EntityManager entityManager;
> 
> @WebMethod(operationName="addAccount")
>       @TransactionAttribute(TransactionAttributeType.REQUIRED)
>       public String addAccount(){
>             String accountCode;
>             Account account =  new Account();
> 
>             account.setAmount(10.0);
>             //…
> 
>             entityManager.persist(account);
>             entityManager.flush();
>             
>             return accountCode;
>       }
> 
> 


-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/EntityManager-dosn-t-release-connection-in-XA-transactions-tp4205041p4207462.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message