akhisyabab

delete data

Nov 9th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. String urlValue="";
  2.        
  3.         Scanner input = new Scanner (System.in);
  4.         System.out.print("Masukkan id yang akan dihapus = ");
  5.         String id = input.nextLine();
  6.        
  7.         try {
  8.             Class.forName("com.mysql.jdbc.Driver");
  9.             urlValue="jdbc:mysql://localhost/pbo?user=root&password=";
  10.             Connection conn=
  11.                     DriverManager.getConnection(urlValue);
  12.            
  13.             Statement st=conn.createStatement();
  14.             boolean rs=st.execute("delete from daftar_pasien WHERE daftar_pasien.id ='"+id+"'");
  15.                
  16.            
  17.             conn.close();
  18.            
  19.         }
  20.            
  21.        
  22.         catch (SQLException e){
  23.             System.out.println("koneksi gagal" + e.toString());
  24.         }
  25.        
  26.         catch (ClassNotFoundException e){
  27.             System.out.println("jdbc.Driver tidak ditemukan");
  28.         }
Add Comment
Please, Sign In to add comment