Anonymous
Asked in
Cars &Transportation
·
2 weeks ago
What happens if you don't close a database connection?
Contents
- Is it necessary to close database connection?
- What happens if SQL connection is not closed?
- Should I keep a database connection open?
- What happens if we don't close the DB connection each time will garbage collector will take care of closing DB connections?
Is it necessary to close database connection?
If you do not close your database connections, many problems can occur like web pages hanging, slow page loads, and more.
What happens if SQL connection is not closed?
Actually, the connection with the database will normally not be closed, but it is simply returned to the connection pool.
Should I keep a database connection open?
Absolutely it is safe to do this. This is how client-server applications work. If you are using a three-tier application, the application server will keep a pool of connections open anyway.
What happens if we don't close the DB connection each time will garbage collector will take care of closing DB connections?
At the end of your JDBC program, it is required explicitly to close all the connections to the database to end each database session. However, if you forget, Java's garbage collector will close the connection when it cleans up stale objects.
Related Questions
Relevance
-
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago
Write us your question, the answer will be received in 24 hours