Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JDBC connection issue with EJB

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are using stateless EJB for this enterprise service. A servlet handles the service request (around 10 million/day) and it in turn invokes the stateless EJB. EJB calls a business delegate (POJO) to get data from database and different external systems.

EJB gets the connection from pool using data source and passes it the delegate. But we need to make database (Oracle) calls in between invoking the external systems. So we make the database call and return the connection (connection.close()) to the pool. We return the connection to the pool to avoid holding the connection till the completion of the external system call.

We are getting connection not available errors. While debugging the issue we noticed that returned connection is not available in the pool.

Is there any property in EJB or connection pool that is holding the connection by the app even though we release it?

Getting connection in EJB:
connection = JDBCConnectionFactory.instance().getConnection();

Get connection method:
public Connection getConnection() throws AppDAOSystemException {
try {
Connection connection = dataSource.getConnection();
return connection;
} catch(SQLException sqlException) {
...
}
}

Return connection method:
public static void returnConnection(Connection connection) {
try {
if(connection != null) {
if(!connection.isClosed()) {
connection.close();
}
connection = null;
}
} catch(SQLException sqlException) {
...
}
}

Thank you all in advance for your help.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic