Anonymous Asked in Cars &Transportation · 2 weeks ago

Should I close connection to database?

If you do not close your database connections, many problems can occur like web pages hanging, slow page loads, and more. Think of it as going through a door to your house. Maybe the door will shut by itself, but maybe it won't. If it doesn't shut, who knows what will happen. 10 нояб. 2011 г.


Should I close DB connection after query?

Don't close your connection unless you are exiting your app, and then make sure you do. Ensure that you are using the same connection when you come back to do more I/O. Database connections are resource-intensive and should be established as few times as possible and shared as much as possible.

What happens if you don't close 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.

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.

Do I need to close SQL connection in using?

If you take the connection outside of the Using statement, then yes - you would need to close the connection when finished. Show activity on this post. No, it is not wrong. The sqlConnection will close the connection after it will pass using block and call Dispose method.

Related Questions

Relevance
Write us your question, the answer will be received in 24 hours