Open Connection even i closed them

F

faisal

hi,

In jboss sometimes even after calling the close method on connection
my db
still shows that it is still open ,and connection is in in active
state

Any suggesstions
 
E

EJP

faisal said:
hi,

In jboss sometimes even after calling the close method on connection
my db
still shows that it is still open ,and connection is in in active
state

It's called connection pooling. Generally held to be a good thing, not a
problem.
 
F

faisal

yes i understand , but in my case it is something like this ..
i start the server which creates an intial pool of 1 connection and when i
call that method from a webservice client since it being exposed as a
webservice.

The method instantiates the connection object which is a local variable
using a wrapper class fetches the data from db ... populate a collection and
then i close the ResultSet , Statement and finally the connection .

i have added logs in between which shows that all the three got closed with
no exception .. but now when i verify the db connection by running a sql
query, it displays me 2 inactive connections .

And when i do netstat on the machine where oracle is installed it shows that
my TCP connection has gone to WAIT state .. and it gets claimed back by
oracle only when TcpTimedWaitDelay is reached...

I dont do any operations in between , no schedulers are there...
 
E

EJP

faisal said:
then i close the ResultSet , Statement and finally the connection .

Closing the connection just returns it to the pool. It doesn't get
really closed until some time later, depending on activity, and the
design of the connection pool. That's the *point*.
 
A

Arne Vajhøj

faisal said:
yes i understand , but in my case it is something like this ..
i start the server which creates an intial pool of 1 connection and when i
call that method from a webservice client since it being exposed as a
webservice.

The method instantiates the connection object which is a local variable
using a wrapper class fetches the data from db ... populate a collection and
then i close the ResultSet , Statement and finally the connection .

i have added logs in between which shows that all the three got closed with
no exception .. but now when i verify the db connection by running a sql
query, it displays me 2 inactive connections .

And when i do netstat on the machine where oracle is installed it shows that
my TCP connection has gone to WAIT state .. and it gets claimed back by
oracle only when TcpTimedWaitDelay is reached...

I dont do any operations in between , no schedulers are there...

Yes.

That is how a connection pool works.

The logic is:
- the pool makes N connections to database at startup
- when the app requests a connection it gets one from the pool
- when the app closes the connection it just gets marked as free
in the pool

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top