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
- 국제화
- 전화걸기
- HTML
- 어노테이션
- 메소드
- oracle
- mybatis
- 오버로딩
- 기본
- paint
- 생성자
- 메서드
- Spring
- struts2
- Java
- 배열
- Android
- layout
- AWT
- 안드로이드
- JavaScript
- 예외처리
- JSP
- Menu
- 이클립스
- 에러페이지
- Eclips
- Graphic
- OGNL
- 클래스
Archives
- Today
- Total
note
JSP DB UPDATE 본문
updateTestForm.jsp 실행화면
아이디가 존재하지 않습니다가 맞는 표현이 아닐까...
<%@ 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"); String name = request.getParameter("name"); 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="update member1 set name= ? where id= ?"; pstmt=conn.prepareStatement(sql); pstmt.setString(1,name); pstmt.setString(2,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 ORACLE DELETE 레코드 삭제 (0) | 2012.02.09 |
JSP 생성한 db 보기 SELECT (0) | 2012.02.08 |
SQL Developper로 DB 테이블 만들기 & JSP로 테이블 레코드 삽입 Insert (0) | 2012.02.08 |