• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic