基于Java+Swing+Mysql实验信息管理系统

一、系统介绍

该系统实现了
用户:已领取实验、实验信息浏览、实验报名、实验详情、我的实验
老师:实验信息浏览、老师打分、
管理员:实验信息录入、实验信息浏览、实验信息删除、实验信息修改

二、功能展示

1.登陆页面

在这里插入图片描述

2.学生页面

在这里插入图片描述

3.老师页面

在这里插入图片描述

4.管理员页面

在这里插入图片描述

三、系统实现

1.UserDao .java

package dao;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import entity.User;
import util.DbUtils;



public class UserDao {
    private Connection conn=null;
    private PreparedStatement ps=null;
    private ResultSet rs=null;
    
    //登陆
    public boolean login(String username,String password){
        String sql="select * from t_user where username='"+ username +"' and password='"+password+"'";
        List<User> list=new ArrayList<User>();
        boolean istrue = false;
        try {
             conn=DbUtils.getConnection();
             ps=conn.prepareStatement(sql);
             rs=ps.executeQuery();
             System.out.println(ps.toString());
             while(rs.next()){
            	 istrue=true;
             }
             DbUtils.close(rs, ps, conn);          
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return istrue;
    }
   //查询用户信息
	public ArrayList<User> selectUser(String username) {
		ArrayList<User> tag_Array = new ArrayList<User>();
		Connection conn = null;
		try {
			conn = DbUtils.getConnection();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		};
		String sql = "select * from t_user where username like '%"+ username +"%'";
		PreparedStatement stm = null;
		ResultSet rs = null;
		try {
			stm = conn.prepareStatement(sql);
			rs = stm.executeQuery();
			while(rs.next()){
				User user = new User();
				user.setUuid(rs.getString("uuid"));
				user.setUsername(rs.getString("username"));
				user.setPassword(rs.getString("password"));
				tag_Array.add(user);
			}			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				DbUtils.close(rs, stm, conn);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return tag_Array;
	}
	//添加用户信息
    public int addUser(String uuid,String username,String password){
    	int result=0;
        String sql="insert into t_user(uuid,username,password) values(?,?,?)";
        try {
        	conn=DbUtils.getConnection();
            ps = conn.prepareStatement(sql);
            ps.setString(1, uuid);
            ps.setString(2, username);
            ps.setString(3, password);
            result =ps.executeUpdate();// 返回值代表收到影响的行数
             DbUtils.close(rs, ps, conn);          
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return result;
    }
    
    //修改用户信息
    public int updateUser(String uuid,String username,String password){
    	int result=0;
        String sql="update t_user set username=?,password=? where uuid =?";
        try {
        	conn=DbUtils.getConnection();
            ps = conn.prepareStatement(sql);          
            ps.setString(1, username);
            ps.setString(2, password);
            ps.setString(3, uuid);
            result =ps.executeUpdate();// 返回值代表收到影响的行数
             DbUtils.close(rs, ps, conn);          
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return result;
    }
    
    //删除
    public int DelUser(String uuid){
    	int result=0;
        String sql="DELETE from t_user where uuid = '" + uuid + "'";
        try {
        	conn=DbUtils.getConnection();
            ps = conn.prepareStatement(sql);
            result =ps.executeUpdate();// 返回值代表收到影响的行数
             DbUtils.close(rs, ps, conn);          
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return result;
    }
}

四、获取源码

点击下载
基于Java+Swing+Mysql实验信息管理系统

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小码叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值