dreamer1989
dreamer1989

Reputation: 1115

why to close Database connection

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

Answers (3)

santosh patar
santosh patar

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

Rajendra
Rajendra

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

Ceetn
Ceetn

Reputation: 2736

It's not really necessary to close your database connection. See this question on stackoverflow for a more detailed explanation.

Upvotes: 0

Related Questions