[LMS]boardList.jsp

ss5Jng·2022년 7월 20일
0
post-thumbnail

벤치마킹 문의사항 게시판

소스코드

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	//인코딩
	request.setCharacterEncoding("utf-8");
	//DB연결
	//#1. Driver 클래스에 로드
	Class.forName("org.mariadb.jdbc.Driver");
	//디버깅
	System.out.println("드라이버 로딩 성공");
	
	//#2  Connection 객체 생성
	Connection conn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/gdj50","root","1234");
	//디버깅
	System.out.println(conn + "<-- conn");
	
	//#3 sql을 담을 stmt 객체 생성
	String sql = "select no,title,userid,create_date FROM board ORDER BY create_date DESC LIMIT 0,10;";
	PreparedStatement stmt = conn.prepareStatement(sql);
	//디버깅
	System.out.println(stmt + "<-- stmt");
	
	//#4 데이터 담을 resultset 객체 생성
	ResultSet rs =  stmt.executeQuery();
	//디버깅
	System.out.println(rs + "<-- rs");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>문의사항</h1>
	<table border="1">
		<tr>
			<th>번호</th>
			<th>제목</th>
			<th>작성자</th>
			<th>작성일</th>
		</tr><!-- end tr -->
		<%
			while(rs.next()){
		%>
		
		<tr>
			<td><%=rs.getInt("no") %></td>
			<td><a href="./boardOne.jsp?no=<%=rs.getInt("no")%>"><%=rs.getString("title")%></a></td>
			<td><%=rs.getString("userid") %></td>
			<td><%=rs.getString("create_date") %></td>
		</tr>
		
		<% 	
			}
		%>
	</table>
</body>
</html>

출력화면

profile
백엔드 개발자입니다:)

0개의 댓글