%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
Insert title here
<%
try{
int no = Integer.parseInt(request.getParameter("no"));
System.out.printf("%d",no);
//오라클에 접속하기 위해서는 드라이버를 로드해야 한다.
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe",
"HR",
"1234");
if (conn == null) {System.out.println("DB접속에 실패");}
else {System.out.println("DB접속 성공");}
String sql = "delete from phonebook where no=?";
PreparedStatement pstmt = conn.prepareStatement(sql); // 위의 SQL문을 처리하기 위해 객체 생성
pstmt.setInt(1, no);
int result = pstmt.executeUpdate();
System.out.println(result +"개가 삭제되었습니다.");
pstmt.close();
conn.close();
response.sendRedirect("list.jsp"); // 전체 테이블 조회해서 확인
}
catch(Exception e){}
finally{}
%>