Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
11 changes: 0 additions & 11 deletions .project

This file was deleted.

107 changes: 107 additions & 0 deletions DB2025Team07.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
DROP DATABASE if exists DB2025Team07;
DROP USER if exists DB2025Team07@localhost;
CREATE USER 'DB2025Team07'@'localhost' IDENTIFIED BY 'DB2025Team07';
CREATE DATABASE DB2025Team07;
GRANT ALL PRIVILEGES ON DB2025Team07.* TO 'DB2025Team07'@'localhost';
USE DB2025Team07;

CREATE TABLE DB2025_Users(
id VARCHAR(7) PRIMARY KEY,
pwd VARCHAR(20) NOT NULL,
nickname VARCHAR(20) NOT NULL,
email VARCHAR(40) UNIQUE NOT NULL,
phone VARCHAR(13) UNIQUE NOT NULL,
rating DECIMAL(3,2) DEFAULT 0.00 CHECK (
rating >= 0.00 AND rating <= 5.00)
);
Describe DB2025_Users;

INSERT INTO DB2025_Users (id, pwd, nickname, email, phone)
VALUES ('2276012', 'hellokim', '화요니._.', 'hellokim@ewhain.net', '010-1234-2276'),
('2276123', 'pwd123', '빵애예요', 'bbangae@ewha.ac.kr', '010-1234-5678'),
('2103123', 'test21ggam', '깜지공듀', 'ggamji@ewhain.net', '010-2103-0123'),
('1955034', '1004@@!!', '소금빵천사', 'saltbreadangel@ewha.ac.kr', '010-3456-7890'),
('2003076','password2003','주니어00', 'junior00@ewha.ac.kr', '010-4567-8901'),
('2271055','abcd1111', '자구요정','dsking@ewhain.net', '010-1111-2222');

SELECT * FROM DB2025_Users;

# 모집글 id 자동으로 설정되게 변경함
CREATE TABLE DB2025_Recruitment(
id INT AUTO_INCREMENT PRIMARY KEY,
user_id VARCHAR(7),
work_place VARCHAR(20) NOT NULL,
start_day DATETIME NOT NULL,
work_period VARCHAR(20) NOT NULL,
salary INT NOT NULL,
# rating은 고유값이 아니라, 동적 값이라 외래키로 받아올 수 없음
# user_id로 user 테이블 조인해서 받아오는 형식으로 참조 가능
# rating을 자주 보여줘야 하는 경우 여기서 view 사용 가능
recruitment_status VARCHAR(10) DEFAULT '모집중'
CHECK (recruitment_status IN ('모집중', '모집마감', '근무완료')),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES DB2025_Users(id) ON DELETE CASCADE
);

Describe DB2025_Recruitment;

INSERT INTO DB2025_Recruitment (user_id, work_place, start_day, work_period, salary, recruitment_status, created_at) VALUES
('2276123', '이화여대 학관', '2025-06-01 09:00:00', '1시간', 5000, '모집중', NOW()),
('2103123', '서울 마포구', '2025-06-15 10:00:00', '3일', 100000, '모집마감', NOW()),
('1955034', '이화여대 이하우스', '2025-07-01 09:30:00', '1일', 50000, '근무완료', NOW()),
('2003076', '이화여대 한우리집', '2025-06-20 08:00:00', '1시간', 10000, '모집중', NOW()),
('2271055', '서울 종로구', '2025-07-10 09:00:00', '2일', 80000, '모집중', NOW());

SELECT * FROM DB2025_Recruitment;

CREATE TABLE DB2025_SUPPORT (
RECRUIT_ID INT NOT NULL,
USER_ID VARCHAR(20) NOT NULL,
RECRUITMENT_STATE ENUM('채택됨', '채택 안됨') DEFAULT '채택 안됨',
SUPPORT_TEXT TEXT,
SUPPORT_CREATED_AT DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (RECRUIT_ID, USER_ID),
FOREIGN KEY (RECRUIT_ID) REFERENCES DB2025_RECRUITMENT(id) ON DELETE CASCADE,
FOREIGN KEY (USER_ID) REFERENCES DB2025_USERS(id) ON DELETE CASCADE
);

DESCRIBE DB2025_SUPPORT;

INSERT INTO DB2025_SUPPORT (
RECRUIT_ID, USER_ID, RECRUITMENT_STATE, SUPPORT_TEXT, SUPPORT_CREATED_AT
) VALUES
(1, '1955034', '채택됨', '바로 도와드릴 수 있어요!', NOW()),
(2, '2276123', '채택 안됨', '오늘 오후에 가능해요!', NOW()),
(3, '1955034', '채택 안됨', '제가 해본 적 있어요. 잘할 수 있습니다.', NOW()),
(4, '2003076', '채택 안됨', '시간 맞춰 드릴 수 있어요!', NOW()),
(5, '2276123', '채택됨', '경험 많아요. 믿고 맡겨주세요!', NOW());

SELECT * FROM DB2025_SUPPORT;

# 내가 작성한 모집글 보기 (뷰) 생성
CREATE OR REPLACE VIEW DB2025_MyRecruits AS
SELECT R.*, U.nickname
FROM DB2025_Recruitment R
JOIN DB2025_Users U ON R.user_id = U.id;

SELECT * FROM DB2025_MyRecruits WHERE user_id = '2276123';

# 내가 작성한 지원글 보기 (뷰) 생성
# 지원한 모집글, 지원자 ID, 지원자 닉네임, 모집글 관련 정보, 채택 여부, 코멘트 내용, 지원시각
CREATE OR REPLACE VIEW DB2025_MySupportApplications AS
SELECT
S.RECRUIT_ID,
S.USER_ID,
U.nickname AS supporter_nickname,
R.work_place,
R.start_day,
R.salary,
S.RECRUITMENT_STATE,
S.SUPPORT_TEXT,
S.SUPPORT_CREATED_AT
FROM DB2025_SUPPORT S
LEFT JOIN DB2025_RECRUITMENT R ON S.RECRUIT_ID = R.id
LEFT JOIN DB2025_USERS U ON S.USER_ID = U.id;
# LEFT JOIN 사용하여 지원글 기준으로 전체 기록 보존

SELECT * FROM DB2025_MySupportApplications WHERE USER_ID = '2276123';
18 changes: 18 additions & 0 deletions DB2025Team07/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="C:/Users/kyung/경희의파일/대학교/4학년-25년도/데베/JDBC 드라이버/mysql-connector-java-8.0.19.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
31 changes: 31 additions & 0 deletions DB2025Team07/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DB2025Team07</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions DB2025Team07/.settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/node_modules/*|**/*.min.js|**/bower_components/*" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
9 changes: 9 additions & 0 deletions DB2025Team07/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21
8 changes: 8 additions & 0 deletions DB2025Team07/.settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="DB2025Team07">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="context-root" value="DB2025Team07"/>
<property name="java-output-path" value="/DB2025Team07/build/classes"/>
</wb-module>
</project-modules>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v9.0"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<installed facet="java" version="21"/>
<installed facet="jst.web" version="4.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Window
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package DB2025Team07;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

@WebServlet("/JoinMemberServlet")
public class DB2025Team07_JoinMemberServlet extends HttpServlet {
static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/DB2025Team07?serverTimezone=UTC";
static final String USER = "DB2025Team07";
static final String PASS = "DB2025Team07";

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

request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");

// HTML form에서 받은 값
String id = request.getParameter("user_id"); // DB에서는 id로 사용됨
String pwd = request.getParameter("pwd");
String nickname = request.getParameter("nickname");
String email = request.getParameter("email");
String phone = request.getParameter("phone");

try {
Class.forName(JDBC_DRIVER);
try (
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
PreparedStatement pstmt = conn.prepareStatement(
"INSERT INTO DB2025_Users (id, pwd, nickname, email, phone) VALUES (?, ?, ?, ?, ?)")
) {
pstmt.setString(1, id);
pstmt.setString(2, pwd);
pstmt.setString(3, nickname);
pstmt.setString(4, email);
pstmt.setString(5, phone);

int result = pstmt.executeUpdate();
PrintWriter out = response.getWriter();

if (result > 0) {
HttpSession session = request.getSession();
session.setAttribute("user_id", id);
session.setAttribute("nickname", nickname);
response.sendRedirect("joinsuccess.jsp"); // <- 개인페이지 대신 success.jsp로 이동
} else {
out.println("<h3>회원가입 실패...</h3>");
}
}
} catch (SQLIntegrityConstraintViolationException dup) {
response.getWriter().println("❗ 중복된 학번/이메일/전화번호입니다.");
} catch (Exception e) {
e.printStackTrace();
response.getWriter().println("DB 오류: " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package DB2025Team07;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

@WebServlet("/LoginServlet")
public class DB2025Team07_LoginServlet extends HttpServlet {
static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/DB2025Team07?serverTimezone=UTC";
static final String USER = "DB2025Team07";
static final String PASS = "DB2025Team07";

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

request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");

String userId = request.getParameter("user_id");
String pwd = request.getParameter("pwd");

try {
// JDBC 드라이버 로드 (중요!)
Class.forName(JDBC_DRIVER);

Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
PreparedStatement pstmt = conn.prepareStatement(
"SELECT * FROM DB2025_Users WHERE id = ? AND pwd = ?");

pstmt.setString(1, userId);
pstmt.setString(2, pwd);

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {
HttpSession session = request.getSession();
session.setAttribute("user_id", userId);
session.setAttribute("nickname", rs.getString("nickname"));

response.sendRedirect("mypage.jsp"); // 로그인 성공 → 마이페이지
} else {
PrintWriter out = response.getWriter();
out.println("<script>alert('학번 또는 비밀번호가 틀렸습니다.');history.back();</script>");
}

// 자원 해제
rs.close();
pstmt.close();
conn.close();

} catch (ClassNotFoundException e) {
e.printStackTrace();
response.getWriter().println("JDBC 드라이버 로드 실패: " + e.getMessage());
} catch (SQLException e) {
e.printStackTrace();
response.getWriter().println("데이터베이스 오류: " + e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package DB2025Team07;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

@WebServlet("/LogoutServlet")
public class DB2025Team07_LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// 현재 세션을 가져와서 무효화
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}

// 로그인 페이지로 리다이렉트
response.sendRedirect("main.jsp");
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
3 changes: 3 additions & 0 deletions DB2025Team07/src/main/webapp/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
15 changes: 15 additions & 0 deletions DB2025Team07/src/main/webapp/joinsuccess.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page session="true" %>
<html>
<head>
<title>회원가입 완료</title>
<meta http-equiv="refresh" content="3;url=mypage.jsp">
</head>
<body>
<%@ include file="navbar.jsp" %>
<h2>회원가입 성공!</h2>
<p>잠시 후에 자동으로 개인 페이지로 이동합니다...</p>
<p><a href="mypage.jsp">바로 이동</a></p>
</body>
</html>
Loading