
# 关闭数据库连接
在使用数据库连接完成相应的数据操作后，需要关闭数据库连接。
关闭数据库连接可以直接调用close方法。
```
conn.close();
```
![](https://support.huaweicloud.com/distributed-devg-v8-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
很多数据库类如Connection、Statement和ResultSet都有close()方法，在使用完对象后应把它们关闭。Connection对象的关闭将间接关闭所有与它关联的Statement对象，Statement对象的关闭将间接关闭ResultSet对象。
