Reputation: 1115
Why should we close a database connection? what can happen if a connection is left open? does the connection gets closed automatically when app exits?
Upvotes: 0
Views: 223
Reputation: 66
1) Open connections as late as possible
2) Close connections as soon as possible
The connection itself is returned to the connection pool. Connections are a limited resource. Any new connection you establish that has exactly the same connection string will be able to reuse the connection from the pool.
Upvotes: 1
Reputation: 1698
To release the resourcess like handler,we should use DBHelper.close(); to close Database, if you not close database,its may arise problem when you try to reconnect to Database. So to overcome this problem , we must close Database.
Upvotes: 0
Reputation: 2736
It's not really necessary to close your database connection. See this question on stackoverflow for a more detailed explanation.
Upvotes: 0