<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
try{
String url ="jdbc:sqlserver://localhost:1433;DatabaseName=QiYe";
String username = "sa";
String password = "sa";
Connection conn =null;
Statement statement = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn =DriverManager.getConnection(url,username,password);
statement sql = "select * from staff";
ResultSet rs =statement.executeQuery(sql);
%>
<table border="0" cellpadding="4" cellspacing="1" bgcolor="#CBD8AC"
width="100%">
<tr align="center" bgcolor="#FAFA1">
<td>编号</td><td>姓名</td><td>性别</td><td>年龄<td></td>部门</td>
</tr>
<%
while (rs.next()){
%>
<tr align="right">
<td><%=rs.getString("Sno")%></td>
<td><%=rs.getString("Sname")%></td>
<td><%=rs.getString("Ssex")%></td>
<td><%=rs.getString("sage")%></td>
<td><%=rs.getString("sdepeterment")%></td></tr>
<%
}
%>
</table>
conn.close();
}catch(Exception e){
e.printStackTrace();
}
</body>
</html>
逆光之羽
叶子
相关分类