权限不足\ }
con.close(); sql.close();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(this, \请输入员工的工号!\ } // }
// else{
// JOptionPane.showMessageDialog(this, \管理员权限不足!\// } }
if (b4.equals(e.getSource())) {// 查询全部员工信息 chaxun=chaxun; chaxun(); }
if (b5.equals(e.getSource())) {// 返回 GZGLZJM gl=new GZGLZJM(name); gl.create(); f.dispose(); }
//查询单条记录
if(b6.equals(e.getSource())){ Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = sql.executeQuery(\* from yg where no='\ int k = 0;
24
if(rs.next()){
for (int i = 0; i < 50; i++) for (int j = 0; j < 6; j++) table.setValueAt(\ //while (rs.next()) {
String no = rs.getString(\
String name = rs.getString(\ String jt = rs.getString(\
String jbgz = rs.getString(\ int sum= rs.getInt(\
String mm = rs.getString(\ table.setValueAt(no, k, 0); table.setValueAt(name, k, 1); table.setValueAt(jt, k, 2); table.setValueAt(jbgz, k, 3); table.setValueAt(sum,k,4); table.setValueAt(mm,k,5); tf6.setText(\ } }
else{
JOptionPane.showMessageDialog(this, \查无此人!\
tf6.setText(\ }
con.close(); sql.close();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(this, \查询失败!\ } } } }
public void actionPerformed(ActionEvent e) {
if (e.getSource()==Button1) {
Connection con;
Statement sql;ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) {
25
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\
sql = con.createStatement(); //
rs=sql.executeQuery(\mm from yg where name='\
String m=null; while(rs.next())
m=rs.getString(\
//System.out.println(password.getText()+\gtrgtrg \
if(m.equals(password.getText())){ sql.executeUpdate(\ yg SET mm='\ JOptionPane.showMessageDialog(this, \修改成功!\
con.close();
frame.dispose(); }
else{
JOptionPane.showMessageDialog(this, \原始密码错误\
}
con.close(); sql.close(); } }
if (e.getSource()==cancelButton) // 返回 {
frame.dispose(); } } }
5.课设总结
此次课设对我来说帮助很大,通过几天的努力终于完成了,开始对如何连接数据库不太了解,通过网上查阅资料,最终解决了问题,
26
在写员工登陆界面时,要从数据库读取和验证密码,开始遇到了些问题,后来慢慢都完成了,总的来说收获很大,了解了如何将所学数据库运用到编程里,对数据库数据的查询,更改,添加都有了更一步的了解。
27