database programming using jsp and mysql n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Database Programming using JSP and MySQL PowerPoint Presentation
Download Presentation
Database Programming using JSP and MySQL

Loading in 2 Seconds...

play fullscreen
1 / 22

Database Programming using JSP and MySQL - PowerPoint PPT Presentation


  • 197 Views
  • Uploaded on

Database Programming using JSP and MySQL. 2003.4.13 Byung-Hyun Ha bhha@pusan.ac.kr. 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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Database Programming using JSP and MySQL' - hisoki


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
database programming using jsp and mysql

Database Programmingusing JSP and MySQL

2003.4.13

Byung-Hyun Ha

bhha@pusan.ac.kr

table of contents
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
database application
Database Application
  • Multi-tier architecture

back-end

front-end

Network

business logic +

presentation layer

DB

back-end

front-end

Network

presentation

layer

business

logic

DB

our database application
Our Database Application
  • 게시판

back-end

front-end

Network

business logic +

presentation layer

DB

Web browser

Internet

JSP page

MySQL

back end architecture
Back-End Architecture
  • Powered by linux

ike.ie.pusan.ac.kr (linux machine)

Apache Tomcat

(Application Server)

MySQL

(DBMS)

Internet

JSP page

(program)

Database

overview of application building
Overview of Application Building
  • Telnet + FTP + MySQL console

ike.ie.pusan.ac.kr

Telnet

daemon

shell

MySQL

Database

Internet

file

system

Tomcat

FTP

daemon

JSP page

(program)

database access via telnet
Database Access via Telnet
  • Login
    • 시작  실행  “telnet ike.ie.pusan.ac.kr”
    • ID와 password 입력
  • Password의 수정
    • passwd
  • Logout
    • exit
  • 다시 login
database access via telnet1
Database Access via Telnet
  • Database console에 login
    • mysql -u uXXXXX -p
    • Password 입력
  • Database console에서 logout
    • quit
  • Password의 수정
    • mysqladmin -u uXXXXX –p password ‘YYYYYYYY’
  • Console에 다시 login
database access via telnet2
Database Access via Telnet
  • 사용 가능한 database 보기
    • show databases;
  • Database 사용
    • use dXXXXX
  • Table 생성
    • create table test(no int, name varchar(20));
  • Table 확인
    • show tables;
  • Record 입력
    • insert into test values(10, ‘abc’);
  • 입력된 내용 확인
    • select * from test;
database access via telnet3
Database Access via Telnet
  • 지금 한 것

ike.ie.pusan.ac.kr

Telnet

daemon

shell

MySQL

Database

Internet

file

system

Tomcat

FTP

daemon

JSP page

(program)

file system access via ftp
File System Access via FTP
  • 테스트 Web page 작성
    • 시작  실행  “notepad”
    • 다음을 입력
    • 바탕 화면에 ‘test.html’로 저장

<html>

<body>

<h1>Hello! HTML!</h1>

</body>

</html>

file system access via ftp1
File System Access via FTP
  • Internet Explorer 실행
  • 주소 창에 다음을 입력
    • ftp://ike.ie.pusan.ac.kr/webapps/
  • 파일  다른 이름으로 로그인
    • 자신의 ike.ie.pusan.ac.kr 계정을 사용하여 로그인
  • ‘test.html’을 Internet Explorer에 drag & drop
  • 새로운 Internet Explorer 실행
    • http://ike.ie.pusan.ac.kr:8080/uXXXXX/test.html
file system access via ftp2
File System Access via FTP
  • 지금 한 것

ike.ie.pusan.ac.kr

Telnet

daemon

shell

MySQL

Database

Internet

file

system

Tomcat

FTP

daemon

JSP page

(program)

file system access via ftp3
File System Access via FTP
  • MySQL을 종료함
  • 현재 경로의 내용확인
    • ls
  • ‘test.html’ 확인
    • cd webapps
    • ls
our first jsp programming
Our First JSP Programming
  • 테스트 JSP page 작성
    • notepad를 열어 다음을 입력하고, ‘test.jsp’로 저장

<html>

<body>

<h1><%= "Hello, JSP! " %></h1>

<%

String str = request.getParameter("name");

if (str != null) {

out.println("You have input " + str);

}

%>

<hr/>

<form name="form1" method="post" action="test.jsp">

Your input? <input type="text" name="name" />

<input type="submit" value="OK" />

</form>

</body>

</html>

our first jsp programming1
Our First JSP Programming
  • ‘test.jsp’를 ike로 전송
  • 결과 확인
our first jsp programming2
Our First JSP Programming
  • 만일 오류가 있다면?
database programming using jsp
Database Programming using JSP
  • ‘list.jsp’의 작성

<%@page import="java.sql.*"%>

<html><body>

<%

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 + "<br/>");

}

rs.close();

stmt.close();

conn.close();

} catch (Exception e) {

out.println(e);

}

%>

<p><a href="insert.jsp">insert</a></p>

</body></html>

database programming using jsp1
Database Programming using JSP
  • ‘insert.jsp’의 작성

<%@page import="java.sql.*"%>

<html><body>

<%

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);

}

}

%>

<form name="form1" method="post" action="insert.jsp">

<input type="text" name="no" /> <input type="text" name="name" /> <input type="submit" value="OK" />

</form> <p><a href="list.jsp">list</a></p>

</body></html>

overview of application building1
Overview of Application Building
  • Telnet + FTP + MySQL console

ike.ie.pusan.ac.kr

Telnet

daemon

shell

MySQL

Database

Internet

file

system

Tomcat

FTP

daemon

JSP page

(program)

database application1
Database Application
  • Multi-tier architecture

back-end

front-end

Network

business logic +

presentation layer

DB

back-end

front-end

Network

presentation

layer

business

logic

DB

discussion
Discussion
  • HTML vs. JSP
  • 한글?
  • 숙제의 의미?