<%@ page contentType = "text/html;charset=euc-kr" %>
<%@ page import = "java.sql.*" %>
<html>
<head>
<title>
테이블의 레코드를 화면에 표시하는 예제
</title>
</head>
<body>
<h2>
member1 테이블의 레코드를 화면에 표시하는 예제
</h2>
<table width = "550" border = "1">
<tr>
<td width = "100">
아이디
</td>
<td width = "100">
패스워드
</td>
<td width = "100">
이름
</td>
<td width = "250">
가입일자
</td>
</tr>
<%
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dbMember", "sa", "123456");
String sql = "select * from Table_2";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
{
String id = rs.getString("ID");
String pw = rs.getString("password");
String name = rs.getString("name");
%>
<tr>
<td width = "100">
<%= id%>
</td>
<td width = "100">
<%= pw%>
</td>
<td width = "100">
<%= name%>
</td>
</tr>
<%
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(rs != null)
{
try
{
rs.close();
}
catch(SQLException sqle)
{
}
}
if(pstmt != null)
{
try
{
pstmt.close();
}
catch(SQLException sqle)
{
}
}
if(con != null)
{
try
{
con.close();
}
catch(SQLException sqle)
{
}
}
}
%>
</table>
</body>
</html>
TRACKBACK http://special0strawberry.tistory.com/trackback/215