1

I make a software with Hibernate + JSF. But realized when I make a session with Hibernate, even though I close a session (session.close()), the connection is still open in MySQL.

show FULL PROCESSLIST

2   root    localhost:55850 repositorionew  Query   0       
5   root    localhost:55884 repositorionew  Sleep   110     
6   root    localhost:55885 repositorionew  Sleep   110     
7   root    localhost:55886 repositorionew  Sleep   110     
8   root    localhost:55906 repositorionew  Sleep   108     
9   root    localhost:55907 repositorionew  Sleep   108

Each session opens, one connect is created but not closed even when I use close.

Someone edited my post. The main problem is that when the time ends of the connection, it does not close but restarts.

Wilson Ribeiro
  • 353
  • 4
  • 19
  • Are you using spring? or Do you have any sort of transaction manager? Also, are you using connection pooling? – Rafa Aug 21 '13 at 21:32
  • this is precisely the problem. C3p0 I use to manage connections. but when I edit the timeout, it does not close the connection, only restarts. When the timeout reaches the number you want, it creates a new connection. and is generating new connections when it reaches the timeout. not use Spring. – Wilson Ribeiro Aug 22 '13 at 12:04

2 Answers2

0

I am guessing that you have one of these two issues:

How can I prevent Hibernate + c3p0 + MySql creating large numbers of sleeping connections?

or

Hibernate : closing the session factory does not close the c3p0 connection pool

I hope that it helps.

Cheers

Community
  • 1
  • 1
Rafa
  • 1,997
  • 3
  • 21
  • 33
0

Is not this default behavior of connection pooling? I don't think that closed session means closed connection. Not in the case of connection pooling at all.

What happen when you close correctly you app?

Martin Podval
  • 1,097
  • 1
  • 7
  • 16
  • Someone edited my post. The main problem is that when the time ends of the connection, it does not close but restarts. – Wilson Ribeiro Aug 22 '13 at 20:16
  • It would correspond to pool as the pool just stores count of active connections equals to some defined number - in configuration. – Martin Podval Aug 22 '13 at 20:26