2个回答
展开全部
public void update() {
Connection conn = DB.getConn();
String sql = "update user set phone = ?, addr = ? where id = ?";
PreparedStatement pstmt = DB.prepare(conn, sql);
try {
pstmt.setString(1, phone);
pstmt.setString(2, addr);
pstmt.setInt(3, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
DB.close(pstmt);
DB.close(conn);
}
}
Connection conn = DB.getConn();
String sql = "update user set phone = ?, addr = ? where id = ?";
PreparedStatement pstmt = DB.prepare(conn, sql);
try {
pstmt.setString(1, phone);
pstmt.setString(2, addr);
pstmt.setInt(3, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
DB.close(pstmt);
DB.close(conn);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询