Anonymous Asked in Cars &Transportation · 2 weeks ago

What happens if you don't close a database connection?

If you don't close it, it leaks, and ties up server resources. @EJP The connection itself might be thread-safe (required by JDBC), but the applications use of the connection is probably not threadsafe. Think of things like different transaction isolation, boundaries (commit/rollback/autocommit) etc. 16 сент. 2014 г.


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
Write us your question, the answer will be received in 24 hours