IDEA+Java+JSP+Mysql+Tomcat实现Web学生信息管理系统
二、系统展示
=====================================================================
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
Ongwu博客 版权声明:以上内容未经允许不得转载!授权事宜或对内容有异议或投诉,请联系站长,将尽快回复您,谢谢合作!