Gucci 將與電競平臺FACEIT合作 建立電競培訓專案
阿新 • • 發佈:2022-05-24
public class mail { private Integer id; private String Sender; private String addressee; private String title; private String content; private String time; private Integer state; public Integer getId() { return id; } public void setId(Integer id) {this.id = id; } public String getSender() { return Sender; } public void setSender(String sender) { Sender = sender; } public String getAddressee() { return addressee; } public void setAddressee(String addressee) { this.addressee = addressee; }public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getTime() {return time; } public void setTime(String time) { this.time = time; } public Integer getState() { return state; } public void setState(Integer state) { this.state = state; } @Override public String toString() { return "mail{" + "id=" + id + ", Sender='" + Sender + '\'' + ", addressee='" + addressee + '\'' + ", title='" + title + '\'' + ", content='" + content + '\'' + ", time='" + time + '\'' + ", state=" + state + '}'; } }
public class MailUsers { private int id; private String username; private String password; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "MailUsers{" + "id=" + id + ", username='" + username + '\'' + ", password='" + password + '\'' + '}'; } }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class mail_UserDao extends mail_BaseDao{ //--------------------使用者登入--------------------- public boolean login(String name, String pwd) { boolean f = false; Connection conn = getConnection(); String sql = "select * from tb_user where username=? and password=?"; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(sql); ps.setString(1, name); ps.setString(2, pwd); rs = ps.executeQuery(); if (rs.next()) f = true; } catch (SQLException e) { e.printStackTrace(); } finally { closeAll(conn, ps, rs); } return f; } //--------------------使用者註冊-------------------- public void reg(String username, String password) { Connection conn = getConnection(); PreparedStatement ps = null; try { String sql = "insert into tb_user(username,password) values(?,?)"; ps = conn.prepareStatement(sql); ps.setString(1, username); ps.setString(2, password); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { closeAll(conn, ps, null); } } } import com.own.mywebdemo.Week5_Login_connecor.BaseDao; import org.jetbrains.annotations.NotNull; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; public class MailDao extends mail_BaseDao { //--------------------查詢所有郵件-------------------- public List<mail> getMailByReceiver(String name){ List<mail> list=new ArrayList<mail>(); Connection conn=getConnection(); String sql="select * from tb_mail where addressee=?"; PreparedStatement ps=null; ResultSet rs=null; try { ps = conn.prepareStatement(sql); ps.setString(1, name); rs=ps.executeQuery(); while(rs.next()){ mail m=new mail(); m.setId(rs.getInt(1)); m.setSender(rs.getString(2)); m.setAddressee(rs.getString(3)); m.setTitle(rs.getString(4)); m.setContent(rs.getString(5)); m.setTime(rs.getString(6)); m.setState(rs.getInt(7)); list.add(m); } } catch (SQLException e) { e.printStackTrace(); }finally{ closeAll(conn, ps, rs); } return list; } // --------------------插入郵件-------------------- public void addMail(mail m) { Connection conn = getConnection(); String sql = "insert into tb_mail(Sender,addressee,title,content,time,state) values(?,?,?,?,?,?)"; PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setString(1, m.getSender()); ps.setString(2, m.getAddressee()); ps.setString(3, m.getTitle()); ps.setString(4, m.getContent()); ps.setDate(5, new java.sql.Date(new Date().getTime()));// 系統當前時間 ps.setInt(6, 0); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { closeAll(conn, ps, null); } } // --------------------刪除郵件-------------------- public void deleteMail(int id) { Connection conn = getConnection(); String sql = "delete from tb_mail where id=?"; PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setInt(1, id); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); }finally{ closeAll(conn, ps, null); } } //--------------------更新郵件狀態-------------------- public void updataMail(int id){ Connection conn = getConnection(); String sql = "update tb_mail set state=1 where id=?"; PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setInt(1, id); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); }finally{ closeAll(conn, ps, null); } } } <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>登入</title> </head> <body> <script type="text/javascript"> function check() { if (login.account.value==""){ alert("請輸入賬號!"); return; }else if(login.psw.value=="") { alert("請輸入密碼!"); return; } login.submit(); } </script> <form action="checkLog.jsp" method="post" name="login"> 賬號:<input type="text" name="account"><br> 密碼:<input type="password" name="psw"><br> <input type="button" value="登入" onclick="check()"> </form><br> <form action="Register.jsp" method="post"> <input type="submit" value="立即註冊賬戶"> </form> </body> </html>