• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC connection issue with EJB  RSS feed

 
mohan govind
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!