Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 메소드
- paint
- 이클립스
- mybatis
- JSP
- 기본
- 국제화
- 배열
- AWT
- layout
- HTML
- 에러페이지
- oracle
- 클래스
- Android
- 메서드
- Eclips
- JavaScript
- Graphic
- Spring
- Menu
- struts2
- 예외처리
- 오버로딩
- 어노테이션
- Java
- 전화걸기
- OGNL
- 안드로이드
- 생성자
Archives
- Today
- Total
note
JSP ORACLE DELETE 레코드 삭제 본문
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>레코드 삭제 예제</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("id");
String passwd = request.getParameter("passwd");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try{
String jdbcUrl ="jdbc:oracle:thin:@localhost:1521:orcl";
String dbId="hr";
String dbPass="hr";
//JDBC수행 1단계 : jdbc Driver 로드
Class.forName("oracle.jdbc.driver.OracleDriver");
//JDBC수행 2단계 : Connection 객체 생성
conn=DriverManager.getConnection(jdbcUrl,dbId,dbPass);
String sql="select id, passwd from member1 where id= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,id);
rs=pstmt.executeQuery();
if(rs.next()){
String rId=rs.getString("id");
String rPasswd=rs.getString("passwd");
if(id.equals(rId) && passwd.equals(rPasswd)){
sql="delete from member1 where id= ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,id);
pstmt.executeUpdate();
%>
member1 테이블의 레코드를 삭제했습니다.
<%
}else{
out.println("패스워드가 틀렸습니다.");
}
}else{
out.println("아이디가 틀렸습니다.");
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs != null)
try{rs.close();}catch(SQLException sqle){}
if(pstmt != null)
try{pstmt.close();}catch(SQLException sqle){}
if(conn != null)
try{conn.close();}catch(SQLException sqle){}
}
%>
</body>
</html>
'Oracle > 기본' 카테고리의 다른 글
| 오라클 계정 생성 , 삭제 (0) | 2012.02.09 |
|---|---|
| JSP 회원 관리 프로그램 (0) | 2012.02.09 |
| JSP DB UPDATE (0) | 2012.02.08 |
| JSP 생성한 db 보기 SELECT (0) | 2012.02.08 |
| SQL Developper로 DB 테이블 만들기 & JSP로 테이블 레코드 삽입 Insert (0) | 2012.02.08 |