

# 数据库连接修改的方法
```public void UpdatePassword(int id,String newPassword){
Connection conn = null;
try {
conn = DBUtils.getConnection();
String sql="update user set password=? where id=?";
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1,newPassword);
ps.setInt(2,id);
ps.executeUpdate();
ps.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtils.closeConnection(conn);
}
}
## ```请问要想实现修改密码的功能怎么写。
不知道你这个问题是否已经解决, 如果还没有解决的话:
如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^