二、系统展示
=====================================================================
1.登录系统
2.主页面
3.增加学生信息
4.修改学生信息
5.查询学生信息
三、代码实现
=====================================================================
AdminDao
package com.sjsq.dao;
import com.sjsq.vo.Admin;
/**
- @author shuijianshiqing
- @date 2021/5/1 9:46
*/
public interface AdminDao {
/**
- 用户登录
- @param admin
- @return
*/
public Admin login(Admin admin);
}
AdminDaoImpl
package com.sjsq.dao.impl;
import com.sjsq.dao.AdminDao;
import com.sjsq.utils.DBUtil;
import com.sjsq.vo.Admin;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
- @author shuijianshiqing
- @date 2021/5/1 9:49
*/
public class AdminDaoImpl implements AdminDao {
/**
- 用户登录
- @param admin
- @return
*/
@Override
public Admin login(Admin admin) {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
// 1.获取数据库连接
con = DBUtil.getConnection();
// 2.写sql
String sql = “select * from admin where username = ? and password = ?”;
// 3.预编译
ps = con.prepareStatement(sql);
// 4.设置值
ps.setObject(1,admin.getUsername());
ps.setObject(2,admin.getPassword());
rs = ps.executeQuery();
Admin adminLogin = null;
if(rs.next()){
adminLogin = new Admin();
// 从数据库中获取值到实体类的setter方法中
adminLogin.setUsername(rs.getString(“username”));
adminLogin.setPassword(rs.getString(“password”));
// 返回的是你查询出来的完整的对象
return adminLogin;
}
} catch (ClassNotFoundException e) {
e.p
版权归原作者 2401_83817148 所有, 如有侵权,请联系我们删除。