After all operations are completed, the connection to the database must be closed.
You can close the connection by using the close method of the Connection object:
conn.close();
Note
Usually, the close statements are placed in the finally clause.