<%@ page contentType="text/html; charset=MS949" %>
<%@ page import="java.sql.*, java.io.*" %>
<%@ page import = "java.sql.DriverManager" %>
<%@ page import = "java.sql.Connection" %>
<%@ page import = "java.sql.Statement" %>
<%@ page import = "java.sql.ResultSet" %>
<%@ page import = "java.sql.SQLException" %>
<html>
<head>
<title>
회원 목록
</title>
</head>
<body bgcolor="#ffffff">
MEMBER 테이블의 내용
<table width="100%" border="1">
<tr>
<td>값1</td><td>값2</td><td>값3</td><td>값4</td>
</tr>
<%
//1. JDBC 드라이버 로딩
Class.forName("com.mysql.jdbc.Driver");
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
String query = " select aid, spid, atitle, aregiste from article, section where (apublish='P01001' or apublish='P02001') and spid=sid and sgroup='3' order by aregiste desc, areg_time desc limit 1 ";
//2.데이터 베이스 커넥션 생성
con = DriverManager.getConnection("jdbc:mysql://디비IP:3306/DB명", "아이디", "암호");
//3. Statement 생성
stmt = con.createStatement();
//4. 쿼리 실행
rs = stmt.executeQuery(query);
//5. 쿼리 실행 결과 출력
while(rs.next()) {
%>
<tr>
<td><%= rs.getString("AID") %></td>
<td><%= rs.getString("SPID")%></td>
<td><%= rs.getString("ATITLE") %></td>
<td><%= rs.getString("AREGISTE") %></td>
</tr>
<%
}
}catch(SQLException ex) {
//에러 발생
System.out.println("프로그램 오류가 있습니다.");
return;
}finally {
//6. 사용한 Statement 종료
if(rs != null) try { rs.close();} catch(SQLException ex) {}
if(stmt != null) try { stmt.close();} catch(SQLException ex) {}
//7. 커넥션 종료
if( con != null) try { con.close(); }catch(SQLException ex) {}
}
%>
</table>
</body>
</html>
이클립스에서 JSP 사용하기 (0) | 2010.10.01 |
---|---|
톰캣구조 및 컨테이너 확인 (0) | 2010.09.11 |
제우스 라이센스기간 만료후 재발급받기 (0) | 2010.08.10 |
티맥스소프트 버전 확인 방법 (0) | 2010.08.10 |
JSP 에러체크 (0) | 2010.08.10 |
댓글 영역