Download presentation
Presentation is loading. Please wait.
Published byOphelia Dalton Modified over 9 years ago
1
Database Programming using JSP and MySQL 2003.4.13 Byung-Hyun Ha bhha@pusan.ac.kr
2
Table of Contents Database Application Overview of Application Building Database Access via Telnet File System Access via FTP First JSP Programming Database Programming using JSP Discussion
3
Database Application Multi-tier architecture front-end back-end Networ k presentation layer business logic DB front-end back-end Networ k business logic + presentation layer DB
4
Our Database Application 게시판 front-end back-end Networ k business logic + presentation layer DB Web browserJSP pageMySQLInternet
5
ike.ie.pusan.ac.kr (linux machine) Back-End Architecture Powered by linux Internet Apache Tomcat (Application Server) JSP page (program) MySQL (DBMS) Database
6
Overview of Application Building Telnet + FTP + MySQL console ike.ie.pusan.ac.kr Telnet daemon Internet FTP daemon shell file system JSP page (program) Database Tomcat MySQL
7
Database Access via Telnet 1.Login 시작 실행 “ telnet ike.ie.pusan.ac.kr ” ID 와 password 입력 2.Password 의 수정 passwd 3.Logout exit 4. 다시 login
8
Database Access via Telnet 1.Database console 에 login mysql -u uXXXXX -p Password 입력 2.Database console 에서 logout quit 3.Password 의 수정 mysqladmin -u uXXXXX –p password ‘YYYYYYYY’ 4.Console 에 다시 login
9
Database Access via Telnet 1. 사용 가능한 database 보기 show databases; 2.Database 사용 use dXXXXX 3.Table 생성 create table test(no int, name varchar(20)); 4.Table 확인 show tables; 5.Record 입력 insert into test values(10, ‘abc’); 6. 입력된 내용 확인 select * from test;
10
Database Access via Telnet ike.ie.pusan.ac.kr Telnet daemon Internet FTP daemon shell file system JSP page (program) Database Tomcat MySQL 지금 한 것
11
File System Access via FTP 테스트 Web page 작성 1. 시작 실행 “ notepad ” 2. 다음을 입력 3. 바탕 화면에 ‘test.html’ 로 저장 Hello! HTML!
12
File System Access via FTP 1.Internet Explorer 실행 2. 주소 창에 다음을 입력 ftp://ike.ie.pusan.ac.kr/webapps/ 3. 파일 다른 이름으로 로그인 자신의 ike.ie.pusan.ac.kr 계정을 사용하여 로그인 4.‘test.html’ 을 Internet Explorer 에 drag & drop 5. 새로운 Internet Explorer 실행 http://ike.ie.pusan.ac.kr:8080/uXXXXX/test.html
13
File System Access via FTP 지금 한 것 ike.ie.pusan.ac.kr Telnet daemon Internet FTP daemon shell file system JSP page (program) Database Tomcat MySQL
14
File System Access via FTP 1.MySQL 을 종료함 2. 현재 경로의 내용확인 ls 3.‘test.html’ 확인 cd webapps ls
15
Our First JSP Programming 테스트 JSP page 작성 notepad 를 열어 다음을 입력하고, ‘test.jsp’ 로 저장 <% String str = request.getParameter("name"); if (str != null) { out.println("You have input " + str); } %> Your input?
16
Our First JSP Programming 1.‘test.jsp’ 를 ike 로 전송 2. 결과 확인
17
Our First JSP Programming 만일 오류가 있다면 ?
18
Database Programming using JSP ‘list.jsp’ 의 작성 <% try { String dbUrl = "jdbc:mysql://localhost/dXXXXX?user=uXXXXX&password=YYYYYY"; Connection conn = DriverManager.getConnection(dbUrl); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM test"); while (rs.next()) { int no = rs.getInt("no"); String name = rs.getString("name"); out.println(no + ", " + name + " "); } rs.close(); stmt.close(); conn.close(); } catch (Exception e) { out.println(e); } %> insert
19
Database Programming using JSP ‘insert.jsp’ 의 작성 <% String no = request.getParameter("no"); String name = request.getParameter("name"); if (no != null && name != null) { try { String dbUrl = "jdbc:mysql://localhost/dXXXXX?user=uXXXXX&password=YYYYYY"; Connection conn = DriverManager.getConnection(dbUrl); Statement stmt = conn.createStatement(); String query = "INSERT INTO test (no, name) VALUES (" + no + ", '" + name + "')"; stmt.execute(query); stmt.close(); conn.close(); out.println("one row inserted."); } catch (Exception e) { out.println(e); } %> list
20
Overview of Application Building Telnet + FTP + MySQL console ike.ie.pusan.ac.kr Telnet daemon Internet FTP daemon shell file system JSP page (program) Database Tomcat MySQL
21
Database Application Multi-tier architecture front-end back-end Networ k presentation layer business logic DB front-end back-end Networ k business logic + presentation layer DB
22
Discussion HTML vs. JSP 한글 ? 숙제의 의미 ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.