<%--
  Created by IntelliJ IDEA.
  User: vie
  Date: 2019/12/30
  Time: 10:04
  To change this template use File | Settings | File Templates.
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,
    minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>学生信息</title>
    <style>
        body{
            background-image: url("Images/bg11.jpg");
        }
    </style>
</head>
<body>
<%
    String driver = "com.mysql.cj.jdbc.Driver";
    String url = "jdbc:mysql://localhost:3306/test?characterEncoding=utf-8"
            +"&serverTimezone=GMT"+ "&useUnicode=true"+"&useSSL=false" ;
    String usr = "root";
    String password = "123456";
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection conn = DriverManager.getConnection(url, usr, password);
    String sqlString = "select * from electricity";
    PreparedStatement pstmt = conn.prepareStatement(sqlString);
    ResultSet rs = pstmt.executeQuery();
%>

<%--<div align="right">欢迎你，<%=request.getParameter("username")%>--%>

<%--    <a href="logout.jsp">退出</a>--%>

<%--</div>--%>

<h2 align="center">宿舍电费列表</h2>

<br>

<table border=1 style="margin:auto">

    <tr>
        <td class="listTable">宿舍号</td>
        <td class="listTable">电费余额</td>
        <td id="operate">操作</td>
    </tr>

    <%
        while (rs.next()) {
            out.println("<tr>");
            out.println("<td>" + rs.getString("Electricity_id") + "</td>");
            out.println("<td>" + rs.getString("Electricity_cost") + "</td>");
            out.println("<td><a href='www.baidu.com'>修改</a></td>");
            out.println("</tr>");
        }
    %>

</table>

<div align="center" style="width: 100%;position: fixed;bottom: 0;color:yellow">
    <%!Date time= new Date();%>
    <%
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日 E HH时mm分ss秒");
    %>
    <h3><% out.println(sdf1.format(time)); %></h3>
</div>
</body>

</html>
