Updated on 2025-03-13 GMT+08:00

Closing a Database Connection

After you complete required data operations in a database, close the database connection.

Call the close method to close the connection.

conn.close();

Many database classes such as Connection, Statement, and ResultSet have a close() method. Close these classes after using their objects. Closing Connection objects closes all the related Statement objects, which in turn closes the related ResultSet objects.