📄 mgloginbean.java
字号:
package Managerlogin;
import java.sql.*;
import java.util.*;
public class MgLoginBean {
private Connection getConnection(){
Connection con=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException ce){
System.out.println("ClassNotFoundException:"+ce.getMessage());
}
try{
con=DriverManager.getConnection("jdbc:odbc:gamezone");
}catch(SQLException e){
System.out.println("SQLException:"+e.getMessage());
}
return con;
}
public boolean checkLogin(String userName,String pwd){
boolean flag=false;
Connection con=null;
ResultSet rs=null;
PreparedStatement stmt=null;
try{
con=getConnection();
stmt=con.prepareStatement("select * from managerInfo where managerName=? and managerPsw=?");
stmt.setString(1,userName);
stmt.setString(2,pwd);
rs=stmt.executeQuery();
if(rs.next()){
flag=true;
}
rs.close();
rs=null;
stmt.close();
stmt=null;
}catch(SQLException e){
System.out.println("checkLogin SQLException="+e.getMessage());
flag=false;
}finally{
if(con!=null){
try{
con.close();
}catch(SQLException e){
System.out.println("SQLException:"+e.getMessage());
}
}
}
return flag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -