0

I have created a connection using connection pool in init() method of servlet and and closing / returning the connection in destroy() method. Basically idea is to use single connection for all time and for all users of application. Now my question is , If users are idle for some time say for 15 mins , does oracle trigger any error related to idle timeout (idle timeout is set to 10 mins.)? and if yes how could i prevent the same ?..

sudhanshu
  • 13
  • 1
  • 6
  • You should always perform `Connection con = /* gather the connection object */` and then when you have finished using the connection then close it in the narrowest possible scope. This is the main idea, regardless if you use a connection pool or not. The job of the connection pool is to maintain the connections inside it alive. You, as programmer, should not try to maintain a `Connection` object alive. – Luiggi Mendoza Jan 31 '18 at 14:08
  • Hi , Thanks for a comment , In my application, previously i was taking connection from connection pool and releasing the same and doing this in doPost() method and this servlet is called for every 15 seconds to check some database activity(to check any modification in table). But this is increasing a load on server and causes too much slowness in application. To prevent it , i took connection in init() method and releasing it in destroy() methos , Now does it make any problem ?? Like if user is logged out for time which is more than idle time set in "user_resource_limits" this table ... – sudhanshu Jan 31 '18 at 14:21
  • You should open and close the connection in your `doPost` method, as you stated. Maybe you were also opening the connections of the connection pool in the `doPost` thus generating an overload of connections. Without seeing the code, I can only speculate the possible issues and causes. – Luiggi Mendoza Jan 31 '18 at 14:46

1 Answers1

0

Seems like by default there is no any timeouts. See this answer for details. In short, there is no timeouts but you can configure it. Also you can configuration dead connection detection.

But if I'm not mistaken you asking if you have such an opportunity to disable it. In short: you may not do anything and everything will work as you wish. But why? You should configure such idle timeouts and dead connection detection if you don't want some user occasionally hang you application with a single connection.

It was the first point. The other one: actually, you should have a connection pool, not a single connection, in order to serve many requests concurrently.

So sorry, the answer is the following: there is no such timeouts by default but I don't understand you intentions:) Hope this helps.

Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74