- 0
- 국내산라이츄
- 조회 수 913
는 2년 전 죽은 제 다이어리...
DB를 액세스에서 저기로 바꿨습니다. mysql...
벗뜨...
엄마 얘 왜 DB를 못가져와......
농담 아니고 궁서체로 진짜 못가져와...OTL
아 그럼 DB에 뭐가 없으니까 그렇지라고 할 수 있죠 근데 봐봐요

뭐가 있어요 심지어 급나 많아요.
(NUM과 STEP2는 total에 대해서 역수 관계입니다. 즉 저 DB에 행만 237개...)
<%@ page import="java.sql.DriverManager"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>diary</title>
</head>
<body>
<%
String dbUrl = "jdbc:mysql://localhost:3306/diary?serverTimezone=UTC";
Class.forName("com.mysql.cj.jdbc.Driver");
try {
Connection conn = DriverManager.getConnection(dbUrl, "root","@Kanamycin1");
Statement stmt = conn.createStatement();
int total = 0;
String SQL = "SELECT COUNT(*) FROM diary";
ResultSet rs = stmt.executeQuery(SQL);
if(rs.next()){
total = rs.getInt(1);
}
rs.close();
out.print("총 게시물 : " + total + "개");
String sqlList = "SELECT NUM, TITLE, TIME, STEP2 FROM diary ORDER BY STEP2 asc";
rs = stmt.executeQuery(sqlList);
%>
<table>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성일</th>
</tr>
<%
if(total==0) {
%>
<tr align="center">
<td colspan="3">등록된 글이 없습니다.</td>
</tr>
<%
} else {
while(rs.next()){
int idx = rs.getInt(1);
String title = rs.getString(2);
String time = rs.getString(3);
%>
<tr>
<td><%=idx %></td>
<td align="left"><%=title %></td>
<td align="center"><%=time %></td>
</tr>
<tr><td colspan="3"></td></tr>
<%
}
}
rs.close();
stmt.close();
conn.close();
out.println("DB에 연결되었습니다. ");
} catch(SQLException e) {
out.print(e.toString());
}
%>
<tr ><td colspan="3"></td></tr>
</table>
</body>
</html>
이게 소스 코드입니다.
코드는 문제없이 잘 돌아가는데 왜 그럴까요... 3_3 혹시 DB랑 테이블이랑 이름 똑같으면 에러 터지나요?
+제가 참고로 콘솔창도 봤습니다. 에러 없었습니다. 서버가 시작되었습니다 하고 끝입니다.
Result set representing update count of 0 <<이건 있네요...
작성자
댓글 0
권한이 없습니다.


