public class Program4 {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		

		int id = 6;
		
		String url = "jdbc:oracle:thin:@localhost:1521/xe";
		String sql = "DELETE NOTICE WHERE ID = ?";
		
			
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection con = DriverManager.getConnection(url,"lec","0000");
		PreparedStatement st = con.prepareStatement(sql);
		st.setInt(1, id);
		
		int result = st.executeUpdate();
		System.out.println(result);
		
		st.close();
		con.close();
			
	}
}

아이디가 6인 데이터가 삭제되었다. 삭제는 UPDATE, INSERT 와 비슷하다.

댓글남기기