Full Code of ZhuangM/student for AI

master 0d722f3a58e2 cached
17 files
38.9 KB
11.4k tokens
96 symbols
1 requests
Download .txt
Repository: ZhuangM/student
Branch: master
Commit: 0d722f3a58e2
Files: 17
Total size: 38.9 KB

Directory structure:
gitextract_5r_0solb/

├── README.md
├── pom.xml
└── src/
    ├── main/
    │   └── java/
    │       └── com/
    │           └── up/
    │               └── student/
    │                   ├── AppConstants.java
    │                   ├── DAO.java
    │                   ├── base/
    │                   │   └── BaseDAO.java
    │                   ├── dao/
    │                   │   ├── AdminDAO.java
    │                   │   └── StudentDAO.java
    │                   ├── model/
    │                   │   ├── Admin.java
    │                   │   └── Student.java
    │                   ├── run/
    │                   │   └── Main.java
    │                   ├── util/
    │                   │   └── DBUtil.java
    │                   └── view/
    │                       ├── AddView.java
    │                       ├── DeleteView.java
    │                       ├── LoginView.java
    │                       ├── MainView.java
    │                       └── UpdateView.java
    └── test/
        └── java/
            └── com/
                └── up/
                    └── demo/
                        └── AppTest.java

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
# student
java swing
默认测试账户:test/test


================================================
FILE: pom.xml
================================================
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.up</groupId>
	<artifactId>student</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>
	<name>student</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.xerial</groupId>
			<artifactId>sqlite-jdbc</artifactId>
			<version>3.23.1</version>
		</dependency>
	</dependencies>

	<build>
		<finalName>student</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
		</plugins>
		<sourceDirectory>src/main/java</sourceDirectory>
		<testSourceDirectory>src/test/java</testSourceDirectory>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
		</testResources>
	</build>
</project>


================================================
FILE: src/main/java/com/up/student/AppConstants.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:41:57
 */
package com.up.student;

/**
 * 模块说明: 常量
 * 
 */
public class AppConstants {
	// jdbc
	public static final String JDBC_URL = "jdbc:sqlite:test.db";
	public static final String JDBC_USERNAME = "test";
	public static final String JDBC_PASSWORD = "test";
	public static final String JDBC_DRIVER = "org.sqlite.JDBC";

	// student field
	public static final String STUDENT_NAME = "姓名";
	public static final String STUDENT_SNO = "学号";
	public static final String STUDENT_SEX = "性别";
	public static final String STUDENT_DEPARTMETN = "院系";
	public static final String STUDENT_HOMETOWN = "籍贯";
	public static final String STUDENT_EMAIL = "电子邮件";
	public static final String STUDENT_TEL = "联系方式";
	public static final String STUDENT_MARK = "学分";

	// login view
	public static final String LOGIN_TITLE = "登录界面";
	public static final String LOGIN_USERNAME = "用户名";
	public static final String LOGIN_PASSWORD = "密码";
	public static final String LOGIN = "登录";
	public static final String RESET = "重置";

	// main view
	public static final String MAINVIEW_TITLE = "学生信息管理系统";
	public static final String MAINVIEW_PAGENUM_JLABEL_DI = "第 ";
	public static final String MAINVIEW_PAGENUM_JLABEL_YE = "/99 页";
	public static final String MAINVIEW_FIND_JLABEL = "查询结果";
	public static final String MAINVIEW_FIRST = "首页";
	public static final String MAINVIEW_LAST = "末页";
	public static final String MAINVIEW_PRE = "上一页";
	public static final String MAINVIEW_NEXT = "下一页";
	public static final String PARAM_FIND_CONDITION = "";
	public static final String PARAM_FIND = "查找";
	public static final String PARAM_ADD = "添加";
	public static final String PARAM_DELETE = "删除";
	public static final String PARAM_UPDATE = "更新";

	// add view
	public static final String ADDVIEW_TITLE = "添加学生信息";
	public static final String ADDVIEW_ADDBUTTON = "添加";
	public static final String EXITBUTTON = "退出";

	// delete view
	public static final String DELETEVIEW_TITLE = "删除学生信息";
	public static final String DELETEVIEW_DELETEBUTTON = "删除";

	// update view
	public static final String UPDATEVIEW_TITLE = "更新学生信息";
	public static final String UPDATEVIEW_UPDATEBUTTON = "更新";

}


================================================
FILE: src/main/java/com/up/student/DAO.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午11:26:11
 */
package com.up.student;

/**
 * 模块说明: 定制枚举类型
 * 
 */
public enum DAO {
	AdminDAO, StudentDAO;

	// private String str;
	//
	// private Clazz(String str) {
	// this.str = str;
	// }
	//
	// public String getStr() {
	// return this.str;
	// }
}


================================================
FILE: src/main/java/com/up/student/base/BaseDAO.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午10:04:37
 */
package com.up.student.base;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.up.student.DAO;
import com.up.student.dao.AdminDAO;
import com.up.student.dao.StudentDAO;
import com.up.student.util.DBUtil;

/**
 * 模块说明: DAO基类
 * 
 */
public abstract class BaseDAO {
	protected final DBUtil db = DBUtil.getDBUtil();
	protected ResultSet rs;
	private static BaseDAO baseDAO;

	public BaseDAO() {
		init();
	}

	private void init() {
		// buildAbilityDAO();
	}

	// protected abstract void buildAbilityDAO();

	public static synchronized BaseDAO getAbilityDAO(DAO dao) {
		switch (dao) {
		case AdminDAO:
			if (baseDAO == null || baseDAO.getClass() != AdminDAO.class) {
				baseDAO = AdminDAO.getInstance();
			}
			break;
		case StudentDAO:
			if (baseDAO == null || baseDAO.getClass() != StudentDAO.class) {
				baseDAO = StudentDAO.getInstance();
			}
			break;
		default:
			break;
		}
		return baseDAO;
	}

	protected void destroy() {
		try {
			if (rs != null) {
				rs.close();
			}
		} catch (SQLException se) {
			se.printStackTrace();
		}
	}
}


================================================
FILE: src/main/java/com/up/student/dao/AdminDAO.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:59:58
 */
package com.up.student.dao;

import java.sql.SQLException;

import com.up.student.base.BaseDAO;

/**
 * 模块说明: 管理员增删改查
 * 
 */
public class AdminDAO extends BaseDAO {

	private static AdminDAO ad = null;

	public static synchronized AdminDAO getInstance() {
		if (ad == null) {
			ad = new AdminDAO();
		}
		return ad;
	}

	public boolean queryForLogin(String username, String password) {
		boolean result = false;
		if (username.length() == 0 || password.length() == 0) {
			return result;
		}
		String sql = "select * from admin where username=? and password=?";
		String[] param = { username, password };
		rs = db.executeQuery(sql, param);
		try {
			if (rs.next()) {
				result = true;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			destroy();
		}
		return result;
	}

}


================================================
FILE: src/main/java/com/up/student/dao/StudentDAO.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午10:00:07
 */
package com.up.student.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.up.student.base.BaseDAO;
import com.up.student.model.Student;

/**
 * 模块说明: 学生增删改查
 * 
 */
public class StudentDAO extends BaseDAO {
	private final int fieldNum = 9;
	private final int showNum = 15;
	private static StudentDAO sd = null;

	public static synchronized StudentDAO getInstance() {
		if (sd == null) {
			sd = new StudentDAO();
		}
		return sd;
	}

	// update
	public boolean update(Student stu) {
		boolean result = false;
		if (stu == null) {
			return result;
		}
		try {
			// check
			if (queryBySno(stu.getSno()) == 0) {
				return result;
			}
			// update
			String sql = "update student set sex=?,department=?,email=?,tel=?,hometown=?,mark=? where name=? and sno=?";
			String[] param = { stu.getSex(), stu.getDepartment(), stu.getEmail(), stu.getTel(), stu.getHomeTown(),
					stu.getMark(), stu.getName(), stu.getSno() };
			int rowCount = db.executeUpdate(sql, param);
			if (rowCount == 1) {
				result = true;
			}
		} catch (SQLException se) {
			se.printStackTrace();
		} finally {
			destroy();
		}
		return result;
	}

	// delete
	public boolean delete(Student stu) {
		boolean result = false;
		if (stu == null) {
			return result;
		}
		String sql = "delete from student where name=? and sno=?";
		String[] param = { stu.getName(), stu.getSno() };
		int rowCount = db.executeUpdate(sql, param);
		if (rowCount == 1) {
			result = true;
		}
		destroy();
		return result;
	}

	// add
	public boolean add(Student stu) {
		boolean result = false;
		if (stu == null) {
			return result;
		}
		try {
			// check
			if (queryBySno(stu.getSno()) == 1) {
				return result;
			}
			// insert
			String sql = "insert into student(name,sno,sex,department,hometown,mark,email,tel) values(?,?,?,?,?,?,?,?)";
			String[] param = { stu.getName(), stu.getSno(), stu.getSex(), stu.getDepartment(), stu.getHomeTown(),
					stu.getMark(), stu.getEmail(), stu.getTel() };
			if (db.executeUpdate(sql, param) == 1) {
				result = true;
			}
		} catch (SQLException se) {
			se.printStackTrace();
		} finally {
			destroy();
		}
		return result;
	}

	// query by name
	public String[][] queryByName(String name) {
		String[][] result = null;
		if (name.length() < 0) {
			return result;
		}
		List<Student> stus = new ArrayList<Student>();
		int i = 0;
		String sql = "select * from student where name like ?";
		String[] param = { "%" + name + "%" };
		rs = db.executeQuery(sql, param);
		try {
			while (rs.next()) {
				buildList(rs, stus, i);
				i++;
			}
			if (stus.size() > 0) {
				result = new String[stus.size()][fieldNum];
				for (int j = 0; j < stus.size(); j++) {
					buildResult(result, stus, j);
				}
			}
		} catch (SQLException se) {
			se.printStackTrace();
		} finally {
			destroy();
		}

		return result;
	}

	// query
	public String[][] list(int pageNum) {
		String[][] result = null;
		if (pageNum < 1) {
			return result;
		}
		List<Student> stus = new ArrayList<Student>();
		int i = 0;
		int beginNum = (pageNum - 1) * showNum;
		String sql = "select * from student limit ?,?";
		Integer[] param = { beginNum, showNum };
		rs = db.executeQuery(sql, param);
		try {
			while (rs.next()) {
				buildList(rs, stus, i);
				i++;
			}
			if (stus.size() > 0) {
				result = new String[stus.size()][fieldNum];
				for (int j = 0; j < stus.size(); j++) {
					buildResult(result, stus, j);
				}
			}
		} catch (SQLException se) {
			se.printStackTrace();
		} finally {
			destroy();
		}

		return result;
	}

	// 将rs记录添加到list中
	private void buildList(ResultSet rs, List<Student> list, int i) throws SQLException {
		Student stu = new Student();
		stu.setId(i + 1);
		stu.setName(rs.getString("name"));
		stu.setDepartment(rs.getString("department"));
		stu.setEmail(rs.getString("email"));
		stu.setHomeTown(rs.getString("hometown"));
		stu.setMark(rs.getString("mark"));
		stu.setSex(rs.getString("sex"));
		stu.setSno(rs.getString("sno"));
		stu.setTel(rs.getString("tel"));
		list.add(stu);
	}

	// 将list中记录添加到二维数组中
	private void buildResult(String[][] result, List<Student> stus, int j) {
		Student stu = stus.get(j);
		result[j][0] = String.valueOf(stu.getId());
		result[j][1] = stu.getName();
		result[j][2] = stu.getSno();
		result[j][3] = stu.getSex();
		result[j][4] = stu.getDepartment();
		result[j][5] = stu.getHomeTown();
		result[j][6] = stu.getMark();
		result[j][7] = stu.getEmail();
		result[j][8] = stu.getTel();
	}

	// query by sno
	private int queryBySno(String sno) throws SQLException {
		int result = 0;
		if ("".equals(sno) || sno == null) {
			return result;
		}
		String checkSql = "select * from student where sno=?";
		String[] checkParam = { sno };
		rs = db.executeQuery(checkSql, checkParam);
		if (rs.next()) {
			result = 1;
		}
		return result;
	}

}


================================================
FILE: src/main/java/com/up/student/model/Admin.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:42:48
 */
package com.up.student.model;

/**
 * 模块说明:admin
 * 
 */
public class Admin {
	private int id;
	private String name;
	private String username;
	private String password;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}


================================================
FILE: src/main/java/com/up/student/model/Student.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:42:36
 */
package com.up.student.model;

/**
 * 模块说明: 学生
 * 
 */
public class Student {
	private int id;
	private String sno;// 学号
	private String name;
	private String sex;
	private String department;// 院系
	private String homeTown;// 籍贯
	private String mark;// 学分
	private String email;
	private String tel;// 联系方式

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSno() {
		return sno;
	}

	public void setSno(String sno) {
		this.sno = sno;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getHomeTown() {
		return homeTown;
	}

	public void setHomeTown(String homeTown) {
		this.homeTown = homeTown;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

}


================================================
FILE: src/main/java/com/up/student/run/Main.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:43:05
 */
package com.up.student.run;

import com.up.student.util.DBUtil;
import com.up.student.view.LoginView;

/**
 * 模块说明:主函数
 * 
 */
public class Main {
	public static void initDB() {
		DBUtil dbUtil = DBUtil.getDBUtil();

		//检查数据库是否初始化
		if (dbUtil.exeute("select 1 from  admin")) {
			return;
		}

		//初始化数据库
		//admin表
		dbUtil.exeute("create table if not exists admin(id int primary key," +
				"name varchar(32)," +
				"username varchar(32)," +
				"password varchar(32))");
		dbUtil.exeute("insert into admin(id, name, username, password) values(1, 'admin', 'test', 'test')");

		//student
		dbUtil.exeute("create table if not exists student(" +
				"id int primary key," +
				"sno varchar(16)," +
				"name varchar(32)," +
				"sex varchar(8)," +
				"department varchar(32)," +
				"hometown varchar(64)," +
				"mark varchar(32)," +
				"email varchar(32)," +
				"tel varchar(16))");
	}

	public static void main(String[] args) {
		initDB();
		new LoginView();
		DBUtil.getDBUtil().close();
	}
}


================================================
FILE: src/main/java/com/up/student/util/DBUtil.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:43:21
 */
package com.up.student.util;

import java.sql.*;

import com.up.student.AppConstants;


/**
 * 模块说明:数据库工具类
 * 
 */
public class DBUtil {
	private static DBUtil db;

	private Connection conn;
	private PreparedStatement ps;
	private ResultSet rs;

	private DBUtil() {

	}

	public static DBUtil getDBUtil() {
		if (db == null) {
			db = new DBUtil();
		}
		return db;
	}

	public int executeUpdate(String sql) {
		int result = -1;
		if (getConn() == null) {
			return result;
		}
		try {
			ps = conn.prepareStatement(sql);
			result = ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return result;
	}

	public int executeUpdate(String sql, Object[] obj) {
		int result = -1;
		if (getConn() == null) {
			return result;
		}
		try {
			ps = conn.prepareStatement(sql);
			for (int i = 0; i < obj.length; i++) {
				ps.setObject(i + 1, obj[i]);
			}
			result = ps.executeUpdate();
			close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return result;
	}

	public ResultSet executeQuery(String sql) {
		if (getConn() == null) {
			return null;
		}
		try {
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return rs;
	}

	public ResultSet executeQuery(String sql, Object[] obj) {
		if (getConn() == null) {
			return null;
		}
		try {
			ps = conn.prepareStatement(sql);
			for (int i = 0; i < obj.length; i++) {
				ps.setObject(i + 1, obj[i]);
			}
			rs = ps.executeQuery();
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return rs;
	}

	public boolean exeute(String sql) {
		if (getConn() == null) {
			return false;
		}
		try {
			Statement statement = conn.createStatement();
			statement.execute(sql);
			statement.close();
			return true;
		} catch (SQLException e) {
//			e.printStackTrace();
			return false;
		}
	}

	private Connection getConn() {
		try {
			if (conn == null || conn.isClosed()) {
				Class.forName(AppConstants.JDBC_DRIVER);
				conn = DriverManager.getConnection(AppConstants.JDBC_URL, AppConstants.JDBC_USERNAME,
						com.up.student.AppConstants.JDBC_PASSWORD);
			}
		} catch (ClassNotFoundException e) {
			System.out.println("jdbc driver is not found.");
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
	}

	public void close() {
		try {
			if (rs != null) {
				rs.close();
			}
			if (ps != null) {
				ps.close();
			}
			if (conn != null) {
				conn.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}


================================================
FILE: src/main/java/com/up/student/view/AddView.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-下午4:56:01
 */
package com.up.student.view;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.up.student.AppConstants;
import com.up.student.DAO;
import com.up.student.base.BaseDAO;
import com.up.student.dao.StudentDAO;
import com.up.student.model.Student;

/**
 * 模块说明: 添加学生
 * 
 */
public class AddView extends JFrame {

	private static final long serialVersionUID = -1984182788841566838L;

	private JPanel jPanelCenter, jPanelSouth;
	private JButton addButton, exitButton;
	private JTextField name, sno, department, hometown, mark, email, tel, sex;

	public AddView() {
		init();
	}

	private void init() {
		setTitle(AppConstants.ADDVIEW_TITLE);
		// center panel
		jPanelCenter = new JPanel();
		jPanelCenter.setLayout(new GridLayout(9, 2));
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_NAME));
		name = new JTextField();
		jPanelCenter.add(name);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_SNO));
		sno = new JTextField();
		jPanelCenter.add(sno);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_SEX));
		sex = new JTextField();
		jPanelCenter.add(sex);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_DEPARTMETN));
		department = new JTextField();
		jPanelCenter.add(department);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_HOMETOWN));
		hometown = new JTextField();
		jPanelCenter.add(hometown);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_MARK));
		mark = new JTextField();
		jPanelCenter.add(mark);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_EMAIL));
		email = new JTextField();
		jPanelCenter.add(email);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_TEL));
		tel = new JTextField();
		jPanelCenter.add(tel);
		jPanelCenter.add(new JLabel("-------------------------------------------------"));
		jPanelCenter.add(new JLabel("-------------------------------------------------"));

		// south panel
		jPanelSouth = new JPanel();
		jPanelSouth.setLayout(new GridLayout(1, 2));
		addButton = new JButton(AppConstants.ADDVIEW_ADDBUTTON);
		addButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (check()) {
					Student stu = new Student();
					buildStudent(stu);
					boolean isSuccess = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).add(stu);
					if (isSuccess) {
						setEmpty();
						if (MainView.currPageNum < 0 || MainView.currPageNum > 99) {
							MainView.currPageNum = 1;
						}
						String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO))
								.list(MainView.currPageNum);
						MainView.initJTable(MainView.jTable, result);
					}
				}
			}
		});
		jPanelSouth.add(addButton);
		exitButton = new JButton(AppConstants.EXITBUTTON);
		exitButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		jPanelSouth.add(exitButton);

		this.add(jPanelCenter, BorderLayout.CENTER);
		this.add(jPanelSouth, BorderLayout.SOUTH);

		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setBounds(470, 200, 400, 270);
		setResizable(false);
		setVisible(true);
	}

	private boolean check() {
		boolean result = false;
		if ("".equals(name.getText()) || "".equals(sno.getText()) || "".equals(department.getText())
				|| "".equals(sex.getText()) || "".equals(mark.getText()) || "".equals(tel.getText())
				|| "".equals(email.getText()) || "".equals(hometown.getText())) {
			return result;
		} else {
			result = true;
		}
		return result;
	}

	private void buildStudent(Student stu) {
		stu.setDepartment(department.getText());
		stu.setEmail(email.getText());
		stu.setHomeTown(hometown.getText());
		stu.setMark(mark.getText());
		stu.setName(name.getText());
		stu.setSno(sno.getText());
		stu.setTel(tel.getText());
		stu.setSex(sex.getText());
	}

	private void setEmpty() {
		name.setText("");
		sno.setText("");
		department.setText("");
		sex.setText("");
		email.setText("");
		hometown.setText("");
		tel.setText("");
		mark.setText("");
	}
}


================================================
FILE: src/main/java/com/up/student/view/DeleteView.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月7日-上午10:27:11
 */
package com.up.student.view;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.up.student.AppConstants;
import com.up.student.DAO;
import com.up.student.base.BaseDAO;
import com.up.student.dao.StudentDAO;
import com.up.student.model.Student;

/**
 * 模块说明: 删除学生
 * 
 */
public class DeleteView extends JFrame {

	private static final long serialVersionUID = -7668153283910203959L;

	private JPanel jPanelCenter, jPanelSouth;
	private JButton deleteButton, exitButton;
	private JTextField name, sno; // 根据姓名+学号删除学生

	public DeleteView() {
		init();
	}

	private void init() {
		setTitle(AppConstants.DELETEVIEW_TITLE);
		// center panel
		jPanelCenter = new JPanel();
		jPanelCenter.setLayout(new GridLayout(3, 2));
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_NAME));
		name = new JTextField();
		jPanelCenter.add(name);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_SNO));
		sno = new JTextField();
		jPanelCenter.add(sno);
		jPanelCenter.add(new JLabel("-------------------------------------------------"));
		jPanelCenter.add(new JLabel("-------------------------------------------------"));

		// south panel
		jPanelSouth = new JPanel();
		jPanelSouth.setLayout(new GridLayout(1, 2));
		deleteButton = new JButton(AppConstants.DELETEVIEW_DELETEBUTTON);
		deleteButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (check()) {
					Student stu = new Student();
					buildStudent(stu);
					boolean isSuccess = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).delete(stu);
					if (isSuccess) {
						setEmpty();
						if (MainView.currPageNum < 0 || MainView.currPageNum > 99) {
							MainView.currPageNum = 1;
						}
						String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO))
								.list(MainView.currPageNum);
						MainView.initJTable(MainView.jTable, result);
					}
				}
			}
		});
		jPanelSouth.add(deleteButton);
		exitButton = new JButton(AppConstants.EXITBUTTON);
		exitButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		jPanelSouth.add(exitButton);

		this.add(jPanelCenter, BorderLayout.CENTER);
		this.add(jPanelSouth, BorderLayout.SOUTH);

		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setBounds(470, 250, 400, 130);
		setResizable(false);
		setVisible(true);
	}

	private boolean check() {
		boolean result = false;
		if ("".equals(name.getText()) || "".equals(sno.getText())) {
			return result;
		} else {
			result = true;
		}
		return result;
	}

	private void buildStudent(Student stu) {
		stu.setName(name.getText());
		stu.setSno(sno.getText());
	}

	private void setEmpty() {
		name.setText("");
		sno.setText("");
	}

}


================================================
FILE: src/main/java/com/up/student/view/LoginView.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-上午9:43:48
 */
package com.up.student.view;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.up.student.AppConstants;
import com.up.student.DAO;
import com.up.student.base.BaseDAO;
import com.up.student.dao.AdminDAO;

/**
 * 模块说明: 登录界面
 * 
 */
public class LoginView extends JFrame {

	private static final long serialVersionUID = -5278598737087831336L;
	private JPanel jPanelCenter, jPanelSouth;
	private JTextField username;
	private JPasswordField password;
	private JButton loginButton, resetButton;

	public LoginView() {
		init();
	}

	private void init() {
		this.setTitle("Login");

		jPanelCenter = new JPanel();
		jPanelCenter.setLayout(new GridLayout(3, 2));
		jPanelCenter.add(new JLabel(AppConstants.LOGIN_USERNAME));
		username = new JTextField();
		jPanelCenter.add(username);
		jPanelCenter.add(new JLabel(AppConstants.LOGIN_PASSWORD));
		password = new JPasswordField();
		// enter key listener
		password.addKeyListener(new LoginListener());
		jPanelCenter.add(password);
		jPanelCenter.add(new JLabel("----------------------------------------------"));
		jPanelCenter.add(new JLabel("----------------------------------------------"));

		jPanelSouth = new JPanel();
		jPanelSouth.setLayout(new GridLayout(1, 2));
		loginButton = new JButton(AppConstants.LOGIN);
		loginButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				check();
			}
		});
		jPanelSouth.add(loginButton);
		resetButton = new JButton(AppConstants.RESET);
		resetButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				username.setText("");
				password.setText("");
			}
		});
		jPanelSouth.add(resetButton);

		this.add(jPanelCenter, BorderLayout.CENTER);
		this.add(jPanelSouth, BorderLayout.SOUTH);

		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setBounds(450, 250, 375, 140);
		this.setResizable(false);
		this.setVisible(true);
	}

	private class LoginListener extends KeyAdapter {

		@Override
		public void keyPressed(KeyEvent e) {
			if (e.getKeyCode() == KeyEvent.VK_ENTER) {
				check();
			}
		}
	}

	private void check() {
		AdminDAO adminDAO = (AdminDAO) BaseDAO.getAbilityDAO(DAO.AdminDAO);
		if (adminDAO.queryForLogin(username.getText(), String.valueOf(password.getPassword()))) {
			dispose();
			new MainView();
		} else {
			username.setText("");
			password.setText("");
		}
	}

}


================================================
FILE: src/main/java/com/up/student/view/MainView.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月6日-下午1:37:39
 */
package com.up.student.view;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import com.up.student.AppConstants;
import com.up.student.DAO;
import com.up.student.base.BaseDAO;
import com.up.student.dao.StudentDAO;

/**
 * 模块说明: 首页
 * 
 */
public class MainView extends JFrame {

	private static final long serialVersionUID = 5870864087464173884L;

	private final int maxPageNum = 99;

	private JPanel jPanelNorth, jPanelSouth, jPanelCenter;
	private JButton jButtonFirst, jButtonLast, jButtonNext, jButtonPre, jButtonAdd, jButtonDelete, jButtonUpdate,
			jButtonFind;
	private JLabel currPageNumJLabel;
	private JTextField condition;
	public static JTable jTable;
	private JScrollPane jScrollPane;
	private DefaultTableModel myTableModel;

	public static String[] column = { "id", AppConstants.STUDENT_NAME, AppConstants.STUDENT_SNO,
			AppConstants.STUDENT_SEX, AppConstants.STUDENT_DEPARTMETN, AppConstants.STUDENT_HOMETOWN,
			AppConstants.STUDENT_MARK, AppConstants.STUDENT_EMAIL, AppConstants.STUDENT_TEL };
	public static int currPageNum = 1;

	public MainView() {
		init();
	}

	private void init() {
		setTitle(AppConstants.MAINVIEW_TITLE);

		// north panel
		jPanelNorth = new JPanel();
		jPanelNorth.setLayout(new GridLayout(1, 5));
		condition = new JTextField(AppConstants.PARAM_FIND_CONDITION);
		condition.addKeyListener(new FindListener());
		jPanelNorth.add(condition);
		// query by name
		jButtonFind = new JButton(AppConstants.PARAM_FIND);
		jButtonFind.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				find();
			}
		});
		jButtonFind.addKeyListener(new FindListener());
		// add
		jPanelNorth.add(jButtonFind);
		jButtonAdd = new JButton(AppConstants.PARAM_ADD);
		jButtonAdd.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				new AddView();
			}
		});
		jPanelNorth.add(jButtonAdd);
		// delete
		jButtonDelete = new JButton(AppConstants.PARAM_DELETE);
		jButtonDelete.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				new DeleteView();
			}
		});
		jPanelNorth.add(jButtonDelete);
		// update
		jButtonUpdate = new JButton(AppConstants.PARAM_UPDATE);
		jButtonUpdate.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				new UpdateView();
			}
		});
		jPanelNorth.add(jButtonUpdate);

		// center panel
		jPanelCenter = new JPanel();
		jPanelCenter.setLayout(new GridLayout(1, 1));

		// init jTable
		String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).list(currPageNum);
		myTableModel = new DefaultTableModel(result, column);
		jTable = new JTable(myTableModel);
		DefaultTableCellRenderer cr = new DefaultTableCellRenderer();
		cr.setHorizontalAlignment(JLabel.CENTER);
		jTable.setDefaultRenderer(Object.class, cr);
		initJTable(jTable, result);

		jScrollPane = new JScrollPane(jTable);
		jPanelCenter.add(jScrollPane);

		// south panel
		jPanelSouth = new JPanel();
		jPanelSouth.setLayout(new GridLayout(1, 5));

		jButtonFirst = new JButton(AppConstants.MAINVIEW_FIRST);
		jButtonFirst.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				currPageNum = 1;
				String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).list(currPageNum);
				initJTable(jTable, result);
				currPageNumJLabel.setText(AppConstants.MAINVIEW_PAGENUM_JLABEL_DI + currPageNum
						+ AppConstants.MAINVIEW_PAGENUM_JLABEL_YE);
			}
		});
		jButtonPre = new JButton(AppConstants.MAINVIEW_PRE);
		jButtonPre.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				currPageNum--;
				if (currPageNum <= 0) {
					currPageNum = 1;
				}
				String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).list(currPageNum);
				initJTable(jTable, result);
				currPageNumJLabel.setText(AppConstants.MAINVIEW_PAGENUM_JLABEL_DI + currPageNum
						+ AppConstants.MAINVIEW_PAGENUM_JLABEL_YE);
			}
		});
		jButtonNext = new JButton(AppConstants.MAINVIEW_NEXT);
		jButtonNext.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				currPageNum++;
				if (currPageNum > maxPageNum) {
					currPageNum = maxPageNum;
				}
				String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).list(currPageNum);
				initJTable(jTable, result);
				currPageNumJLabel.setText(AppConstants.MAINVIEW_PAGENUM_JLABEL_DI + currPageNum
						+ AppConstants.MAINVIEW_PAGENUM_JLABEL_YE);
			}
		});
		jButtonLast = new JButton(AppConstants.MAINVIEW_LAST);
		jButtonLast.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				currPageNum = maxPageNum;
				String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).list(currPageNum);
				initJTable(jTable, result);
				currPageNumJLabel.setText(AppConstants.MAINVIEW_PAGENUM_JLABEL_DI + currPageNum
						+ AppConstants.MAINVIEW_PAGENUM_JLABEL_YE);
			}
		});

		currPageNumJLabel = new JLabel(
				AppConstants.MAINVIEW_PAGENUM_JLABEL_DI + currPageNum + AppConstants.MAINVIEW_PAGENUM_JLABEL_YE);
		currPageNumJLabel.setHorizontalAlignment(JLabel.CENTER);

		jPanelSouth.add(jButtonFirst);
		jPanelSouth.add(jButtonPre);
		jPanelSouth.add(currPageNumJLabel);
		jPanelSouth.add(jButtonNext);
		jPanelSouth.add(jButtonLast);

		this.add(jPanelNorth, BorderLayout.NORTH);
		this.add(jPanelCenter, BorderLayout.CENTER);
		this.add(jPanelSouth, BorderLayout.SOUTH);

		setBounds(400, 200, 750, 340);
		setResizable(false);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setVisible(true);
	}

	public static void initJTable(JTable jTable, String[][] result) {
		((DefaultTableModel) jTable.getModel()).setDataVector(result, column);
		jTable.setRowHeight(20);
		TableColumn firsetColumn = jTable.getColumnModel().getColumn(0);
		firsetColumn.setPreferredWidth(30);
		firsetColumn.setMaxWidth(30);
		firsetColumn.setMinWidth(30);
		TableColumn secondColumn = jTable.getColumnModel().getColumn(1);
		secondColumn.setPreferredWidth(60);
		secondColumn.setMaxWidth(60);
		secondColumn.setMinWidth(60);
		TableColumn thirdColumn = jTable.getColumnModel().getColumn(2);
		thirdColumn.setPreferredWidth(90);
		thirdColumn.setMaxWidth(90);
		thirdColumn.setMinWidth(90);
		TableColumn fourthColumn = jTable.getColumnModel().getColumn(3);
		fourthColumn.setPreferredWidth(30);
		fourthColumn.setMaxWidth(30);
		fourthColumn.setMinWidth(30);
		TableColumn seventhColumn = jTable.getColumnModel().getColumn(6);
		seventhColumn.setPreferredWidth(30);
		seventhColumn.setMaxWidth(30);
		seventhColumn.setMinWidth(30);
		TableColumn ninthColumn = jTable.getColumnModel().getColumn(8);
		ninthColumn.setPreferredWidth(90);
		ninthColumn.setMaxWidth(90);
		ninthColumn.setMinWidth(90);
	}

	private class FindListener extends KeyAdapter {

		@Override
		public void keyPressed(KeyEvent e) {
			if (e.getKeyCode() == KeyEvent.VK_ENTER) {
				find();
			}
		}
	}

	private void find() {
		currPageNum = 0;
		String param = condition.getText();
		if ("".equals(param) || param == null) {
			initJTable(MainView.jTable, null);
			currPageNumJLabel.setText(AppConstants.MAINVIEW_FIND_JLABEL);
			return;
		}
		String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).queryByName(param);
		condition.setText("");
		initJTable(MainView.jTable, result);
		currPageNumJLabel.setText(AppConstants.MAINVIEW_FIND_JLABEL);
	}

}


================================================
FILE: src/main/java/com/up/student/view/UpdateView.java
================================================
/**
 * 项目名:student
 * 修改历史:
 * 作者: MZ
 * 创建时间: 2016年1月7日-上午11:07:57
 */
package com.up.student.view;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.up.student.AppConstants;
import com.up.student.DAO;
import com.up.student.base.BaseDAO;
import com.up.student.dao.StudentDAO;
import com.up.student.model.Student;

/**
 * 模块说明: 更新学生信息
 * 
 */
public class UpdateView extends JFrame {

	private static final long serialVersionUID = 5292738820127102731L;

	private JPanel jPanelCenter, jPanelSouth;
	private JButton updateButton, exitButton;
	private JTextField name, sno, department, hometown, mark, email, tel, sex;

	public UpdateView() {
		init();
	}

	private void init() {
		setTitle(AppConstants.UPDATEVIEW_TITLE);
		// center panel
		jPanelCenter = new JPanel();
		jPanelCenter.setLayout(new GridLayout(9, 2));
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_NAME));
		name = new JTextField();
		jPanelCenter.add(name);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_SNO));
		sno = new JTextField();
		jPanelCenter.add(sno);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_SEX));
		sex = new JTextField();
		jPanelCenter.add(sex);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_DEPARTMETN));
		department = new JTextField();
		jPanelCenter.add(department);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_HOMETOWN));
		hometown = new JTextField();
		jPanelCenter.add(hometown);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_MARK));
		mark = new JTextField();
		jPanelCenter.add(mark);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_EMAIL));
		email = new JTextField();
		jPanelCenter.add(email);
		jPanelCenter.add(new JLabel(AppConstants.STUDENT_TEL));
		tel = new JTextField();
		jPanelCenter.add(tel);
		jPanelCenter.add(new JLabel("-------------------------------------------------"));
		jPanelCenter.add(new JLabel("-------------------------------------------------"));

		// south panel
		jPanelSouth = new JPanel();
		jPanelSouth.setLayout(new GridLayout(1, 2));
		updateButton = new JButton(AppConstants.UPDATEVIEW_UPDATEBUTTON);
		updateButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (check()) {
					Student stu = new Student();
					buildStudent(stu);
					boolean isSuccess = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO)).update(stu);
					if (isSuccess) {
						setEmpty();
						if (MainView.currPageNum < 0 || MainView.currPageNum > 99) {
							MainView.currPageNum = 1;
						}
						String[][] result = ((StudentDAO) BaseDAO.getAbilityDAO(DAO.StudentDAO))
								.list(MainView.currPageNum);
						MainView.initJTable(MainView.jTable, result);
					}
				}
			}
		});
		jPanelSouth.add(updateButton);
		exitButton = new JButton(AppConstants.EXITBUTTON);
		exitButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		jPanelSouth.add(exitButton);

		this.add(jPanelCenter, BorderLayout.CENTER);
		this.add(jPanelSouth, BorderLayout.SOUTH);

		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setBounds(470, 200, 400, 270);
		setResizable(false);
		setVisible(true);
	}

	private boolean check() {
		boolean result = false;
		if ("".equals(name.getText()) || "".equals(sno.getText()) || "".equals(department.getText())
				|| "".equals(sex.getText()) || "".equals(mark.getText()) || "".equals(tel.getText())
				|| "".equals(email.getText()) || "".equals(hometown.getText())) {
			return result;
		} else {
			result = true;
		}
		return result;
	}

	private void buildStudent(Student stu) {
		stu.setDepartment(department.getText());
		stu.setEmail(email.getText());
		stu.setHomeTown(hometown.getText());
		stu.setMark(mark.getText());
		stu.setName(name.getText());
		stu.setSno(sno.getText());
		stu.setTel(tel.getText());
		stu.setSex(sex.getText());
	}

	private void setEmpty() {
		name.setText("");
		sno.setText("");
		department.setText("");
		sex.setText("");
		email.setText("");
		hometown.setText("");
		tel.setText("");
		mark.setText("");
	}
}


================================================
FILE: src/test/java/com/up/demo/AppTest.java
================================================
package com.up.demo;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * Unit test for simple App.
 */
public class AppTest 
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( AppTest.class );
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp()
    {
        assertTrue( true );
    }
}
Download .txt
gitextract_5r_0solb/

├── README.md
├── pom.xml
└── src/
    ├── main/
    │   └── java/
    │       └── com/
    │           └── up/
    │               └── student/
    │                   ├── AppConstants.java
    │                   ├── DAO.java
    │                   ├── base/
    │                   │   └── BaseDAO.java
    │                   ├── dao/
    │                   │   ├── AdminDAO.java
    │                   │   └── StudentDAO.java
    │                   ├── model/
    │                   │   ├── Admin.java
    │                   │   └── Student.java
    │                   ├── run/
    │                   │   └── Main.java
    │                   ├── util/
    │                   │   └── DBUtil.java
    │                   └── view/
    │                       ├── AddView.java
    │                       ├── DeleteView.java
    │                       ├── LoginView.java
    │                       ├── MainView.java
    │                       └── UpdateView.java
    └── test/
        └── java/
            └── com/
                └── up/
                    └── demo/
                        └── AppTest.java
Download .txt
SYMBOL INDEX (96 symbols across 15 files)

FILE: src/main/java/com/up/student/AppConstants.java
  class AppConstants (line 13) | public class AppConstants {

FILE: src/main/java/com/up/student/DAO.java
  type DAO (line 13) | public enum DAO {

FILE: src/main/java/com/up/student/base/BaseDAO.java
  class BaseDAO (line 21) | public abstract class BaseDAO {
    method BaseDAO (line 26) | public BaseDAO() {
    method init (line 30) | private void init() {
    method getAbilityDAO (line 36) | public static synchronized BaseDAO getAbilityDAO(DAO dao) {
    method destroy (line 54) | protected void destroy() {

FILE: src/main/java/com/up/student/dao/AdminDAO.java
  class AdminDAO (line 17) | public class AdminDAO extends BaseDAO {
    method getInstance (line 21) | public static synchronized AdminDAO getInstance() {
    method queryForLogin (line 28) | public boolean queryForLogin(String username, String password) {

FILE: src/main/java/com/up/student/dao/StudentDAO.java
  class StudentDAO (line 21) | public class StudentDAO extends BaseDAO {
    method getInstance (line 26) | public static synchronized StudentDAO getInstance() {
    method update (line 34) | public boolean update(Student stu) {
    method delete (line 61) | public boolean delete(Student stu) {
    method add (line 77) | public boolean add(Student stu) {
    method queryByName (line 103) | public String[][] queryByName(String name) {
    method list (line 134) | public String[][] list(int pageNum) {
    method buildList (line 166) | private void buildList(ResultSet rs, List<Student> list, int i) throws...
    method buildResult (line 181) | private void buildResult(String[][] result, List<Student> stus, int j) {
    method queryBySno (line 195) | private int queryBySno(String sno) throws SQLException {

FILE: src/main/java/com/up/student/model/Admin.java
  class Admin (line 13) | public class Admin {
    method getName (line 19) | public String getName() {
    method setName (line 23) | public void setName(String name) {
    method getId (line 27) | public int getId() {
    method setId (line 31) | public void setId(int id) {
    method getUsername (line 35) | public String getUsername() {
    method setUsername (line 39) | public void setUsername(String username) {
    method getPassword (line 43) | public String getPassword() {
    method setPassword (line 47) | public void setPassword(String password) {

FILE: src/main/java/com/up/student/model/Student.java
  class Student (line 13) | public class Student {
    method getId (line 24) | public int getId() {
    method setId (line 28) | public void setId(int id) {
    method getSno (line 32) | public String getSno() {
    method setSno (line 36) | public void setSno(String sno) {
    method getName (line 40) | public String getName() {
    method setName (line 44) | public void setName(String name) {
    method getSex (line 48) | public String getSex() {
    method setSex (line 52) | public void setSex(String sex) {
    method getDepartment (line 56) | public String getDepartment() {
    method setDepartment (line 60) | public void setDepartment(String department) {
    method getHomeTown (line 64) | public String getHomeTown() {
    method setHomeTown (line 68) | public void setHomeTown(String homeTown) {
    method getMark (line 72) | public String getMark() {
    method setMark (line 76) | public void setMark(String mark) {
    method getEmail (line 80) | public String getEmail() {
    method setEmail (line 84) | public void setEmail(String email) {
    method getTel (line 88) | public String getTel() {
    method setTel (line 92) | public void setTel(String tel) {

FILE: src/main/java/com/up/student/run/Main.java
  class Main (line 16) | public class Main {
    method initDB (line 17) | public static void initDB() {
    method main (line 46) | public static void main(String[] args) {

FILE: src/main/java/com/up/student/util/DBUtil.java
  class DBUtil (line 18) | public class DBUtil {
    method DBUtil (line 25) | private DBUtil() {
    method getDBUtil (line 29) | public static DBUtil getDBUtil() {
    method executeUpdate (line 36) | public int executeUpdate(String sql) {
    method executeUpdate (line 50) | public int executeUpdate(String sql, Object[] obj) {
    method executeQuery (line 68) | public ResultSet executeQuery(String sql) {
    method executeQuery (line 81) | public ResultSet executeQuery(String sql, Object[] obj) {
    method exeute (line 98) | public boolean exeute(String sql) {
    method getConn (line 113) | private Connection getConn() {
    method close (line 129) | public void close() {

FILE: src/main/java/com/up/student/view/AddView.java
  class AddView (line 30) | public class AddView extends JFrame {
    method AddView (line 38) | public AddView() {
    method init (line 42) | private void init() {
    method check (line 116) | private boolean check() {
    method buildStudent (line 128) | private void buildStudent(Student stu) {
    method setEmpty (line 139) | private void setEmpty() {

FILE: src/main/java/com/up/student/view/DeleteView.java
  class DeleteView (line 30) | public class DeleteView extends JFrame {
    method DeleteView (line 38) | public DeleteView() {
    method init (line 42) | private void init() {
    method check (line 98) | private boolean check() {
    method buildStudent (line 108) | private void buildStudent(Student stu) {
    method setEmpty (line 113) | private void setEmpty() {

FILE: src/main/java/com/up/student/view/LoginView.java
  class LoginView (line 32) | public class LoginView extends JFrame {
    method LoginView (line 40) | public LoginView() {
    method init (line 44) | private void init() {
    class LoginListener (line 89) | private class LoginListener extends KeyAdapter {
      method keyPressed (line 91) | @Override
    method check (line 99) | private void check() {

FILE: src/main/java/com/up/student/view/MainView.java
  class MainView (line 36) | public class MainView extends JFrame {
    method MainView (line 56) | public MainView() {
    method init (line 60) | private void init() {
    method initJTable (line 199) | public static void initJTable(JTable jTable, String[][] result) {
    class FindListener (line 228) | private class FindListener extends KeyAdapter {
      method keyPressed (line 230) | @Override
    method find (line 238) | private void find() {

FILE: src/main/java/com/up/student/view/UpdateView.java
  class UpdateView (line 30) | public class UpdateView extends JFrame {
    method UpdateView (line 38) | public UpdateView() {
    method init (line 42) | private void init() {
    method check (line 116) | private boolean check() {
    method buildStudent (line 128) | private void buildStudent(Student stu) {
    method setEmpty (line 139) | private void setEmpty() {

FILE: src/test/java/com/up/demo/AppTest.java
  class AppTest (line 10) | public class AppTest
    method AppTest (line 18) | public AppTest( String testName )
    method suite (line 26) | public static Test suite()
    method testApp (line 34) | public void testApp()
Condensed preview — 17 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (47K chars).
[
  {
    "path": "README.md",
    "chars": 38,
    "preview": "# student\njava swing\n默认测试账户:test/test\n"
  },
  {
    "path": "pom.xml",
    "chars": 1467,
    "preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\txsi:schemaLoca"
  },
  {
    "path": "src/main/java/com/up/student/AppConstants.java",
    "chars": 2208,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:41:57\n */\npackage com.up.student;\n\n/**\n * 模块说明: 常量\n * \n */\n"
  },
  {
    "path": "src/main/java/com/up/student/DAO.java",
    "chars": 315,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午11:26:11\n */\npackage com.up.student;\n\n/**\n * 模块说明: 定制枚举类型\n * "
  },
  {
    "path": "src/main/java/com/up/student/base/BaseDAO.java",
    "chars": 1142,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午10:04:37\n */\npackage com.up.student.base;\n\nimport java.sql.Re"
  },
  {
    "path": "src/main/java/com/up/student/dao/AdminDAO.java",
    "chars": 874,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:59:58\n */\npackage com.up.student.dao;\n\nimport java.sql.SQLE"
  },
  {
    "path": "src/main/java/com/up/student/dao/StudentDAO.java",
    "chars": 4941,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午10:00:07\n */\npackage com.up.student.dao;\n\nimport java.sql.Res"
  },
  {
    "path": "src/main/java/com/up/student/model/Admin.java",
    "chars": 697,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:42:48\n */\npackage com.up.student.model;\n\n/**\n * 模块说明:admin\n"
  },
  {
    "path": "src/main/java/com/up/student/model/Student.java",
    "chars": 1364,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:42:36\n */\npackage com.up.student.model;\n\n/**\n * 模块说明: 学生\n *"
  },
  {
    "path": "src/main/java/com/up/student/run/Main.java",
    "chars": 1074,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:43:05\n */\npackage com.up.student.run;\n\nimport com.up.studen"
  },
  {
    "path": "src/main/java/com/up/student/util/DBUtil.java",
    "chars": 2613,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:43:21\n */\npackage com.up.student.util;\n\nimport java.sql.*;\n"
  },
  {
    "path": "src/main/java/com/up/student/view/AddView.java",
    "chars": 4265,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-下午4:56:01\n */\npackage com.up.student.view;\n\nimport java.awt.Bor"
  },
  {
    "path": "src/main/java/com/up/student/view/DeleteView.java",
    "chars": 3044,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月7日-上午10:27:11\n */\npackage com.up.student.view;\n\nimport java.awt.Bo"
  },
  {
    "path": "src/main/java/com/up/student/view/LoginView.java",
    "chars": 2810,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-上午9:43:48\n */\npackage com.up.student.view;\n\nimport java.awt.Bor"
  },
  {
    "path": "src/main/java/com/up/student/view/MainView.java",
    "chars": 8096,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月6日-下午1:37:39\n */\npackage com.up.student.view;\n\nimport java.awt.Bor"
  },
  {
    "path": "src/main/java/com/up/student/view/UpdateView.java",
    "chars": 4297,
    "preview": "/**\n * 项目名:student\n * 修改历史:\n * 作者: MZ\n * 创建时间: 2016年1月7日-上午11:07:57\n */\npackage com.up.student.view;\n\nimport java.awt.Bo"
  },
  {
    "path": "src/test/java/com/up/demo/AppTest.java",
    "chars": 639,
    "preview": "package com.up.demo;\n\nimport junit.framework.Test;\nimport junit.framework.TestCase;\nimport junit.framework.TestSuite;\n\n/"
  }
]

About this extraction

This page contains the full source code of the ZhuangM/student GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 17 files (38.9 KB), approximately 11.4k tokens, and a symbol index with 96 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!