基于java的Swing+MySQL考试系统java基础gui(java+gui)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

360123042402

370123042402

380123042402

390123042402

基于java的Swing+MySQL考试系统java基础gui(java+gui)

功能简介:

所属课程、题目内容、题目选项、题目答案、题目等级、学生管理、试卷管理、题目管理、时间控制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
					paper.setPid(0);
for (int i = 1; i < listUser.size(); i++) {
User user = listUser.get(i);

int pid = user.getPaper().getPid();
user.setPaper(null);
userManage.update(user);
Paper paper1 = paperManage.findById(pid);
paperManage.delete(paper1);
}
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}
}

// 用来得到试卷的题目列表

public static String getListTitle(List<Title> listTitles) {

String listTitle = null;
// 用来存放5个等级的题目序列 1,2,3,4,5
int title1[] = new int[1];
int n1 = 0;
int title2[] = new int[1];
int n2 = 0;
// int title3[] = new int[1];
// int n3 = 0;
// int title4[] = new int[1];
// int n4 = 0;
// int title5[] = new int[1];
// int n5 = 0;
// int title6[] = new int[1];
// int n6 = 0;
// int title7[] = new int[1];
// int n7 = 0;
// int title8[] = new int[1];
// int n8 = 0;
// int title9[] = new int[1];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
					JOptionPane
.showMessageDialog(UpdateStudentFrame.this, "update success!!!");
}
});
} catch (Exception e) {
// add your error handling code here
e.printStackTrace();
}

jButton2.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
jTextField3.setText("");

}
});

}

}
package com.xinyue.daoimp;



public class UserDAO implements IUserDAO {

private IPaperDAO ipaperDAO = new PaperDAO();

public static void main(String[] args) throws StudentExistException {
User st = new User();
st.setName("111");
st.setPassword("111");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

String findSql = "select * from t_user where uid=" + id;
User user = new User();
try {
Connection con = DBcon.getDBcon().getConnection();
PreparedStatement ps = con.prepareStatement(findSql);
ResultSet rs = ps.executeQuery();
while (rs.next()) {

String name = rs.getString(2);
String password = rs.getString(3);
int paperId = rs.getInt(4);

user.setUid(id);
user.setName(name);
user.setPassword(password);
user.setPaper(ipaperDAO.findById(paperId));
}
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return user;
}

@Override
public boolean save(User user) throws StudentExistException {
int uid = user.getUid();
User user1 = findById(uid);

if (null != user1.getName())
throw new StudentExistException("该学生已存在");

String saveSql = "insert into t_user values(?,?,?,?)";

try {
Connection con = DBcon.getDBcon().getConnection();
PreparedStatement ps = con.prepareStatement(saveSql);

// paperDAO.save(user.getPaper());
ps.setString(1, null);
ps.setString(2, user.getName());
ps.setString(3, user.getPassword());
System.out.println(user.getName());

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
* Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose
* whatever) then you should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
* ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class UpdateStudentFrame extends javax.swing.JFrame {
private static final long serialVersionUID = 1L;

/**
* Auto-generated main method to display this JFrame
*/

private JButton jButton1;
private JLabel jLabel2;
private JTextField jTextField4;
private JTextField jTextField3;
private JTextField jTextField2;
private JTextField jTextField1;
private JButton jButton2;
private JLabel jLabel1;
private JLabel jLabel10;
private JLabel jLabel7;
private JLabel jLabel8;
private JPanel jPanel1;
private User user;
private int paper;

/**
*
*/

// 注入UserManage
private static UserManage userManage = new UserManageImp();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
		String listTitle = null;
// 用来存放5个等级的题目序列 1,2,3,4,5
int title1[] = new int[1];
int n1 = 0;
int title2[] = new int[1];
int n2 = 0;
// int title3[] = new int[1];
// int n3 = 0;
// int title4[] = new int[1];
// int n4 = 0;
// int title5[] = new int[1];
// int n5 = 0;
// int title6[] = new int[1];
// int n6 = 0;
// int title7[] = new int[1];
// int n7 = 0;
// int title8[] = new int[1];
// int n8 = 0;
// int title9[] = new int[1];
// int n9 = 0;
// int title10[] = new int[1];
// int n10 = 0;
Title title = null;
for (int i = 0; i < listTitles.size(); i++) {
title = listTitles.get(i);
if (title.getLevel() == 1) {
title1[n1] = title.getTid();
n1++;
// 数组扩容
int length = title1.length;
title1 = Arrays.copyOf(title1, length + 1);
}

if (title.getLevel() == 2) {
title2[n2++] = title.getTid();
int length = title2.length;
title2 = Arrays.copyOf(title2, length + 1);
}

// if (title.getLevel() == 3) {
// title3[n3++] = title.getTid();
// int length = title3.length;
// title3 = Arrays.copyOf(title3, length + 1);
// }
//
// if (title.getLevel() == 4) {
// title4[n4++] = title.getTid();
// int length = title4.length;
// title4 = Arrays.copyOf(title4, length + 1);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
													.createSequentialGroup()
.addGap(23)
.addComponent(
jButton1,
GroupLayout.PREFERRED_SIZE,
71,
GroupLayout.PREFERRED_SIZE)
.addGap(0, 70,
Short.MAX_VALUE)
.addComponent(
jButton2,
GroupLayout.PREFERRED_SIZE,
79,
GroupLayout.PREFERRED_SIZE)))
.addContainerGap(116, 116));
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
jPanel1, 0, 317, Short.MAX_VALUE));
layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(
jPanel1, 0, 441, Short.MAX_VALUE));

pack();
this.setSize(457, 355);
// 置中
this.setLocationRelativeTo(null);
this.setVisible(true);
}// </editor-fold>

// GEN-END:initComponents

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args
* the command line arguments


项目链接:
https://javayms.github.io?id=241222062008200ww
https://javayms.pages.dev?id=241222062008200ww