웹프로그래밍 응용(JSP) - 1주차 ~ 2주차
<1주차>
필요한 소프트웨어
■JDK - java SE 8u321
java 애플리케이션을 구축하기 위한 핵심 플랫폼 구성요소. java 컴파일러가 포함되어있다.
■Tomcat - version 9
Apache 웹서버 + Java코드를 서버사이드에서 실행시켜주는 애플리케이션 서버.
■Eclipse - 최신버전
프로그램을 작성하고 디버깅하는 IDE
■MySQL - version 5.7.9
관계형 데이터베이스 시스템
JDK 설치
https://www.oracle.com/java/technologies/downloads/
Download the Latest Java LTS Free
Subscribe to Java SE and get the most comprehensive Java support available, with 24/7 global access to the experts.
www.oracle.com
※dbconn.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306","root","12345");
out.println("데이터베이스 연결 성공");
}catch(SQLException e){
out.println("데이터베이스 연결 실패");
out.println(e.getMessage());
}finally{
if(conn != null)
conn.close();
}
%>
</body>
</html>
이클립스 mysql db 연동방법
https://coinco.tistory.com/110
file -> new -> Dynamic web Project
이름:test
test -> webapp -> new -> Jsp file
이름:Aaa.jsp
이클립스 Database 연동하기 [MySQL , Oracle]
안녕하세요 . 대충벌레 입니다. 이클립스로 데이터베이스 연동하는 방법입니다. 이클립스 하단에 보시면 Data Source Explorer이 있습니다. 저는 현재 두개다 추가해 놓은 상태이고 처음하시는 분들
coinco.tistory.com
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
int i;
for(i=0; i<10; i++){
out.println("Hello");
}
%>
</body>
</html>
mysql db
->use mydb; 명령어 치고 데이터베이스 들어가기
db 구문
create table board(
-> num int not null auto_increment,
-> subject varchar(100) not null,
-> content varchar(1000) not null,
-> name varchar(100) not null,
-> password varchar(100) not null,
-> signdate DATETIME not null,
-> primary key(num));
mysql> use mydb;
Database changed
mysql> create table board(
-> num int not null auto_increment,
-> subject varchar(100) not null,
-> content varchar(1000) not null,
-> name varchar(100) not null
-> password varchar(100) not null,
-> signdate DATETIME not null,
-> primary key(num));
Query OK, 0 rows affected (0.03 sec)
insert into board(subject,content,name,password,signdate) values('sub1','content1','name1','pass',now());
insert into board(subject,content,name,password,signdate) values('sub2','content2','name1','pass',now());
insert into board(subject,content,name,password,signdate) values('sub3','content3','name1','pass',now());
insert into board(subject,content,name,password,signdate) values('sub4','content4','name1','pass',now());
insert into board(subject,content,name,password,signdate) values('sub5','content5','name1','pass',now());