tags:

views:

51

answers:

1

I am creating a web service using j2ee. this webservice is hitting DB to insert/update data. We are using Connection drivers to eshtablish connection to database. When we launch this web service and tested it, we got a Memory Leak issue and hence the transaction failed. The folliwng is the error message we obtained: "Memory allocation failed during query processing "

This issue was solved when we restarted the weblogic server. This static connection object is only used by EJBs for handling DB transactions.

Will this single static connection object will create memory leak issue and will cause the transaction to fail?

Note: Please dont advice to close the connection, since we need it throughout the transaction.

A: 
  1. You should always retrieve a connection from the connection pool (Datasource) configured on the server (using jndi)
  2. You should never keep your Connection object static
  3. You should always close() you connection in the finally block. (when you retrieve a connection from a Datasource and call close(), you simply tell the pool that you are done with your connection. You don't actually close it.

Do these and you should be fine.

Ryan Fernandes