?? registerbean.java
字號:
//package eshop;import java.util.*;import java.sql.*;public class RegisterBean { Connection conn; boolean registerResult; public RegisterBean() { registerResult=false; } public void setConn(Connection conn){ this.conn=conn; } public boolean register(String username,String password,String question,String answer){ try { Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); String sql1="SELECT * FROM Customers WHERE Username='"+username+"'"; ResultSet rsLogin=stmt.executeQuery(sql1); if(rsLogin.next()){ this.registerResult=false; }else{ String sql2="INSERT INTO Customers(Username,Password,Question,Answer) VALUES('"+username+"','"+password+"','"+question+"','"+answer+"')"; stmt.executeUpdate(sql2); this.registerResult=true; } rsLogin.close(); stmt.close(); }catch(SQLException e){ e.printStackTrace(); } return this.registerResult; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -