Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void editData(int id, String jenisRuang, float hargaSewa) {
- System.out.println("**EDIT DATA**");
- try {
- conn = DriverManager.getConnection(url, user, password);
- String query = "UPDATE ruang SET jenis_ruang=?, harga_sewa=? WHERE id_ruang=?";
- pst = conn.prepareStatement(query);
- pst.setString(1, jenisRuang);
- pst.setFloat(2, hargaSewa);
- pst.setInt(3, id);
- int rowsAffected = pst.executeUpdate();
- if (rows
- if (rowsAffected > 0) {
- System.out.println("Data berhasil diubah.");
- } else {
- System.out.println("Gagal mengubah data.");
- }
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- } finally {
- try {
- if (pst != null) {
- pst.close();
- }
- if (conn != null) {
- conn.close();
- }
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
- System.out.println("==============================");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement