I have several questions about database connection and database sessions. I assume questions below are apply to all databases (RDBMS).

  1. In most of the cases, one database session is on one database connection. If client close the DB connection, will the DB session terminate straight away?

  2. If the DB session contain a row level lock created via select for update query, will closing the DB connection without commit or rollback release the lock?

  3. What is the impact if database statements are not close?

  • I read an article mentioned that close connection will rollback the pending transaction. – kenn3th Feb 15 '17 at 19:26
  1. If the DB connection is closed the session will get an error the next time it attempts to query the database. But will work on subsequent tries as it establishes a new connection.

  2. I believe this answer varies by RDBMS, but to answer you question, I believe the general answer is no. You can however manually kill the session, which should release the locks.

  3. You should commit or rollback your transactions, you should not leave them open.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.