-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Siena JDBC doesn't close connections to the data base #2
Comments
Hello ! It isn't to the user the responsibility to close the connection ? For JDBC, Siena close statement and result set, but I think you have to close the connection yourself. I may be mistaken, but Siena can't know when it's the right moment to close the connection. Please Try something like User.getPersistantManager().closeConnection(); |
All ORMs that I know manage the connection for you. When you do a connection.close() you just give the connection back to the pool and the pool decides if needs to close the connection or reuse it. |
Ok, I think that I understand the issue : after each request (get/delete/...), Siena should close the connection, because, as you said, the pool will close or reuse the connection. But for non pooled connection, it shouldn't close the connection ? Am I right ? (my knowledge about pooled connection/jdbc is poor, sorry for this noob question ;)) |
Not sure about using non pooled connections thought and ORM. I never used an ORM without a pool of connections. Best practices using JDBC with a noon pooled connections are open the connection, do all your operations, close the connection. Siena and other ORM, are not able to know when you finish using the connection. Some random ideas:
|
Siena has an abstract connection manager which provides DB connections and closes them. Basically Siena doesn't care if there is a pool of connections or anything else. It just asks for a connection and closes it when finished. |
I have testing the problem with the latest release of siena (siena-1.0.0-b6-SNAPSHOT) and it has the same problem.
Replicating the problem
pool max connections = 10
Thread with TaskExecutor to keep the threads there.
Result: Every thread blocks its connections, so connections never released.
Sample code
Console output
More information about how to manage connections using JDBC and pools
http://stackoverflow.com/questions/2313197/jdbc-mysql-connection-pooling-practices
http://stackoverflow.com/questions/4938517/closing-jdbc-connections-in-pool
The text was updated successfully, but these errors were encountered: