} }
//登录DAO验证
package com.xinzhan.dao;
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException;
import com.xinzhan.demo.LoginFrame;
public class LoginDAO {
public LoginDAO(){ }
public static boolean checkLogin(){ //获得用户名 String
userName
=
LoginFrame.textField.getText(); //获得密码 String
userPwd
=
String.valueOf(LoginFrame.passwordField.getPassword()); Connection
con
=
DbManager.getCon();//连接数据库 String sql = \count(*) from admin where name=? and pwd=?\
int num = 0; ResultSet rs = null;
PreparedStatement pst = null; try {
pst = con.prepareStatement(sql); pst.setString(1, userName); pst.setString(2, userPwd); rs = pst.executeQuery(); while(rs.next()){ num = rs.getInt(1); }
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
DbManager.closeAll(rs, pst, con); }
if(num>0){ return true; }else{ return false; } } }
//学员管理DAO类 package com.xinzhan.dao;
import java.sql.Connection; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.SQLException;
import com.xinzhan.demo.LoginFrame;
public class LoginDAO {
public LoginDAO(){ }
public static boolean checkLogin(){ //获得用户名 String
userName
LoginFrame.textField.getText(); //获得密码
=
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库java做的一个小学员管理系统(2)在线全文阅读。
相关推荐: