-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_check.jsp
62 lines (45 loc) · 1.88 KB
/
main_check.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<%@ page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%
// 이전 페이지로부터 온 값 인코딩 설정
request.setCharacterEncoding("utf-8");
String user_id = (String)session.getAttribute("idValue");
// 이전 페이지로부터 값 받아오는 부분
String contentValue=request.getParameter("content");
String dateValue=request.getParameter("date");
String ampmValue=request.getParameter("ampm");
int hourValue;
if(ampmValue.equals("오전")){
hourValue=Integer.parseInt(request.getParameter("hour"));
}
else{
hourValue=Integer.parseInt(request.getParameter("hour"))+12;
}
String minuteValue=request.getParameter("minute");
String TodoDateValue = dateValue+" " + hourValue + ":"+minuteValue+ ":00";
// 커넥터를 불러오는 명령어 줄
Class.forName("com.mysql.jdbc.Driver");
// DB 주소, 계정 아이디, 비밀번호 적어주기 mysql포트는 3306 : DB 연결 작업
Connection connect=DriverManager.getConnection("jdbc:mysql://localhost:3306/Calendarium", "se" , "1234" );
String sql="INSERT INTO Todo (userID, userTodo, TodoDate, commentAvailable) VALUES (?, ?, ?, ?)";
PreparedStatement query =connect.prepareStatement(sql);
query.setString(1, user_id);
query.setString(2, contentValue);
query.setString(3, TodoDateValue);
query.setInt(4, 1);
query.executeUpdate();
%>
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<script>
window.history.back();
</script>
</body>