简单学生选课系统之学分汇总

时间:2023-01-19 19:10:41

简单学生选课系统之学分汇总

ScDao.java

 public ResultSet selectcredit(){
ResultSet rst=null;
Coon coona=new Coon();
Connection coonn=coona.getCoon();
String sql="select scno,sno,sname from sc group by sno having sum(ccredit)<15";
try {
PreparedStatement pst=coonn.prepareStatement(sql);
rst=pst.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rst;
}


queryStudent.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="nuc.select.Dao.*" %>
<!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>查询学分不够情况</title>
<style type="text/css">
td{
text-align:center;
}
</style>
</head>

<body>
<center>
<%
request.setCharacterEncoding("utf-8");
ScDao sc=new ScDao();
ResultSet rs=sc.selectcredit();
if(rs!=null){
%>
<table border="1" width="500" height="500">
<caption>学分不够的情况</caption>
<tr><td>班级</td><td>学号</td><td>姓名</td></tr>
<%
while(rs.next()){
%>
<tr>
<td><%=rs.getString("scno") %></td>
<td><%=rs.getString("sno") %></td>
<td><%=rs.getString("sname") %></td>
</tr>
<%
}
}else{
out.println("没有学分不够的学生!");
}
%>
</table>
</center>
</body>
</html>