java

ํ”„๋กœ์ ํŠธ(2) - ํ™”๋ฉด์„ค๊ณ„

dev_summer 2020. 11. 12. 16:42

 

 

1. ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์„ ์ •

์ฒ˜์Œ์—” ์›น๋””์ž์ด๋„ˆ ์นœ๊ตฌ๊ฐ€ ์ค€ ํŽ˜์ด์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋ ค ํ•˜์˜€์œผ๋‚˜ ์—ฌ๋Ÿฌ ์„œ๋ธŒํŽ˜์ด์ง€๋“ค๊ณผ ํ†ต์ผ์„ฑ์žˆ๊ฒŒ ๋Œ๋ฆฌ๊ธฐ ์œ„ํ•ด ๊ตฌ๊ธ€์—์„œ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํ…œํ”Œ๋ฆฟ์„ ๊ฒ€์ƒ‰ํ•˜์—ฌ ์„ ํƒํ•˜์˜€๋‹ค.

๋‚ด๊ฐ€ ๋งŒ๋“ค๊ณ ์‹ถ์€ ํŽ˜์ด์ง€๋Š” ์ œํ’ˆ๋ฆฌ์ŠคํŠธ๊ฐ€ ๋ฟŒ๋ ค์ง€๊ณ  ์ œํ’ˆ์˜ ์ƒ์„ธ๋ณด๊ธฐ๊ฐ€ ๊ฐ€๋Šฅํ•œ ํ™”๋ฉด์ด ๋ฟŒ๋ ค์ง€๋Š” ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ์—ˆ๋‹ค. ๋˜ ๋ฌธ์˜๊ฒŒ์‹œํŒ๊ณผ ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž…๋“ฑ์ด ๊ฐ€๋Šฅํ•œ ํ™”๋ฉด์ด ์žˆ์–ด์•ผ ํ•˜๋Š”๋ฐ ์ด๊ฒƒ์€ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํ…œํ”Œ๋ฆฟ์ด ์•„๋‹Œ ๋ฉ”๋‰ด๋ฐ”์™€ ํ‘ธํ„ฐ ์‚ฌ์ด์— ์ผ๋ฐ˜์ ์ธ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํผ์„ ๋„ฃ์„ ์ƒ๊ฐ์ด๋‹น.

 

 

 

 

์ƒํ’ˆ๋ชฉ๋ก์œผ๋กœ ๋ฐ”๊ฟ€ ํŽ˜์ด์ง€

 

์ƒํ’ˆ์˜ ์ƒ์„ธ๋ณด๊ธฐ ํ™”๋ฉด

 

2. ์ปค์Šคํ„ฐ๋งˆ์ด์ง•

 

 

์ปค์Šคํ„ฐ๋งˆ์ด์ง• ํ•œ ๋ฉ”์ธํŽ˜์ด์ง€

 

 

3. ํ•„์š”ํ•œ ํŽ˜์ด์ง€ ํ™•์ธ ๋ฐ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ™•์ธํ•˜๊ธฐ

 

 

ring ํŽ˜์ด์ง€ ๋ฆฌ์ŠคํŠธ

 

perfuem ๋ฆฌ์ŠคํŠธ

 

watch ๋ฆฌ์ŠคํŠธ

* ๋ฆฌ์ŠคํŠธ ํŽ˜์ด์ง€๋Š” ์ƒ๋‹จ์˜ ๋ฉ”์ธ์ด๋ฏธ์ง€๊ต์ฒด, ๊ฐ๊ฐ์˜ DBํ…Œ์ด๋ธ”์„ ๊ตฌ์ถ•ํ•˜์—ฌ ํฐ ํ‹€์€ ๊ฐ™๋„๋ก ๋งŒ๋“ค ์˜ˆ์ •

 

 

 

 

 

๊ฐ ์ œํ’ˆ๋ณ„ ๋””ํ…Œ์ผ ํŽ˜์ด์ง€

 

 

 

 

 

 

์ œํ’ˆ ์—…๋กœ๋“œ ํ™”๋ฉด

 

 

 

 

๋กœ๊ทธ์ธํŽ˜์ด์ง€

 

 

 

ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€

 

 

 

 

ํšŒ์› ์ˆ˜์ • ํŽ˜์ด์ง€

 

 

 

๋…ธํ‹ฐ์Šค ๋ฆฌ์ŠคํŠธ ํŽ˜์ด์ง€

 

 

 

๋…ธํ‹ฐ์Šค ๊ธ€์“ฐ๊ธฐ,์ˆ˜์ •

 

 

 

DB

 

 

html ๊ตฌ์„ฑ

JAVA

 

 

 

 

4.๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ํ…Œ์ด๋ธ” ์ƒ์„ฑ

 

 

show variables like 'C%';

https://blog.naver.com/mooo4030/221765257347

 

 

root์œผ๋กœ ๋“ค์–ด๊ฐ€์„œ ์•ž์œผ๋กœ ์‚ฌ์šฉํ•  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค

create user 'seoha'@'%' identified by '๋น„๋ฐ€๋ฒˆํ˜ธ'; // seoha ์•„์ด๋””์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ƒ์„ฑํ•˜์˜€๋‹น
create database seoha; // seoha DB๋ฅผ ๋งŒ๋“ค์—ˆ๋‹น 
grant all privileges on seoha.* to 'seoha'@'%' // seoha์—๊ฒŒ ๋ชจ๋“  ๊ถŒํ•œ์„ ์ฃผ์—ˆ๋‹น

 

 

 

 

์š”๋กœ์ผ€ ์ž˜ ์…‹ํŒ…์ด ๋˜์–ด๋”ฐ

 

 

 

 

5. ํŒฉํ† ๋ฆฌ์…‹ํŒ…, DB์—ฐ๊ฒฐ

 

DB์—ฐ๊ฒฐ ๋‚ด๊ฐ€ ์ ค๋ฃจ ํ—ท๊ฐˆ๋ ธ๋˜ ๋ถ€๋ถ„์ด๋‹ค ๋”ฐํํ‘ ใ… ใ… 

์ด๋ฒˆ์—์•ผ๋ง๋กœ ์—ฐ๊ฒฐํ•˜๋Š” ๋งˆ๋ฌด์œผ๋ฆฌ๋ฅผ ํ•˜๊ฒŸ๋‹ค

 

 

(1). web-inf์˜ web.xml๊ณผ meta-inf์— ์žˆ๋Š” context.xml์— ์žˆ๋Š” ํŒŒ์ผ์„ ์ˆ˜์ •ํ•œ๋‹ค

 

(2). DButil.java ์™€ model๋งŒ๋“ค๊ธฐ

์—ฌ๊ธฐ์„œ ๋ชจ๋ธ์€ ์ฒ˜์Œ๋ถ€ํ„ฐ ๋กฌ๋ถ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒŒํ„ฐ์™€์„ธํ„ฐ๋“ฑ์„ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ค„์ˆ˜์žˆ๊ฒŒ ์–ด๋…ธํ…Œ์ด์…˜๋งŒ ๊ฑธ์–ด๋†“๊ฒ ๋‹ค!

 

 

package com.seoho.tiffany.model;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder

public class User {
	int userno;
	String userid;
	String username;
	String password;
	String email;
	String address;
	int tel;
	Timestamp createTime;
	
}

 

(3) ์ปจํŠธ๋กค๋Ÿฌ ํ…Œ์ŠคํŠธํ•ด๋ณด๊ธฐ

package test;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.seoho.tiffany.action.Action;
import com.seoho.tiffany.action.user.UserFactory;
import com.seoho.tiffany.model.User;


@WebServlet("/User")
public class UserControllerTest extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	doPost(request, response);		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		UserDaoTest test = new UserDaoTest();
		int user = test.save();
		System.out.println(user);
		
	}

}

 

 

 

์ค‘๊ฐ„์— ์•ฝ๊ฐ„ ๊ฐ์„ ๋ชป์žก๊ธด ํ–ˆ์ง€๋งŒ ๊ทธ๋ž˜๋„ ์„ฑ๊ณต

์ƒ๊ฐํ•ด๋ณด๋‹ˆ ์•„์ด๋””์— ์œ ๋‹ˆํ๋ฅผ ์•ˆ๊ฑธ์—ˆ๋‹ค.. ๊ฑธ๊ณ ์™€์•ผ์ง€

 

ALTER TABLE `seoha`.`user` 
ADD UNIQUE INDEX `userid_UNIQUE` (`userid` ASC),
ADD UNIQUE INDEX `userno_UNIQUE` (`userno` ASC);
;

 

 

 

 

6. model, viewmodel, actionํŒŒ์ผ ์ƒ์„ฑ

 

 

๋งž๋‚˜?

dao, dto,util์€ ๋‹ค์Œ๊ธฐํšŒ์— ์ •๋ฆฌ :-)

 

7. include ์ƒ์„ฑ

8. ํŽ˜์ด์ง€ ์ƒ์„ฑ

 

 

 

 

 

๊ฐ ํ™”๋ฉด๋“ค ์ƒ์„ฑ ์™„๋ฃŒ!!!!

์ด์ œ ์ง„์งœ ์‹œ์ž‘์ด๋‹น