t2 = new String(password.getPassword()); if(e.getSource()==logonButton1){ try {
Connection con; Statement sql; ResultSet rs;
Class.forName(\
//Class.forName(\//驱动
con = DriverManager.getConnection(
\ sql=con.createStatement();
rs=sql.executeQuery(\ glname,power,glmm from gly where glname='\查询
//power=rs.getString(\ if(rs.next()) {
if(rs.getString(\&& rs.getString(\ {
name=t1;
GZGLZJM yg = new GZGLZJM(name); frame.dispose();
yg.create();
//JOptionPane.showMessageDialog(new DL(), \登录成功!\
if(JOptionPane.YES_OPTION==0){frame.dispose(); // // } } }
else {
JOptionPane.showMessageDialog(this, \输入用户名或密码错误!\ }
con.close(); sql.close();
}catch (Exception e1) {
// TODO Auto-generated catch block e1.printStackTrace(); } }
if (e.getSource()==logonButton2)
9
{
try {
Connection con; Statement sql; ResultSet rs;
Class.forName(\;
//Class.forName(\//驱动
con = DriverManager.getConnection(
\ sql=con.createStatement();
rs=sql.executeQuery(\ * from yg where name='\查询
if(rs.next()) {
if(rs.getString(\&& rs.getString(\ {
name=t1;
YGDLJM yg = new YGDLJM(name); frame.dispose(); yg.create();
JOptionPane.showMessageDialog(new DL(), \登录成功!\
if(JOptionPane.YES_OPTION==0){frame.dispose(); }
else {
JOptionPane.showMessageDialog(this, \输入用户名或密码错误!\ }
con.close(); sql.close();
}catch (Exception e1) {
// TODO Auto-generated catch block e1.printStackTrace(); } }
if (cancelButton.equals(e.getSource())) // 退出
{
10
System.exit(0); } } }
public void chaxun(){ Connection con; Statement sql; ResultSet rs;
//Vector vector = new Vector(); try {
Class.forName(\ } catch (ClassNotFoundException e1) {
JOptionPane.showMessageDialog(this, \连接数据库失败!\ }
try { con = DriverManager.getConnection(\ba\ sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE); //if (b4.equals(\查询所有\
for (int i = 0; i < 50; i++) for (int j = 0; j < 4; j++) table.setValueAt(\ rs = sql.executeQuery(\ no,name,jbgz,jt from yg\ int k = -1;
while (rs.next()) { ++k;
String no = rs.getString(1); String name = rs.getString(2); String jbgz = rs.getString(3); String jt = rs.getString(4);
//int sum= rs.getInt(3)+rs.getInt(4); table.setValueAt(no, k, 0);
11
table.setValueAt(name, k, 1); table.setValueAt(jbgz, k, 2); table.setValueAt(jt, k, 3); //table.setValueAt(sum,k,4);
}
con.close(); sql.close(); }
catch (SQLException e1) {
if(chaxun.equals(\ {
JOptionPane.showMessageDialog(this, \查询失败\
}
else{
JOptionPane.showMessageDialog(this, \刷新失败!\
} } }
public void actionPerformed(ActionEvent e) { if (b1.equals(e.getSource())) { // 录入 Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) { System.out.println(\ }
try {
con=DriverManager.getConnection(\:3306/dba\
sql = con.createStatement();
rs=sql.executeQuery(\* from gly where glname='\
while(rs.next()){
power=rs.getString(\ }
rs=null;
12
if(power.equals(\ try{ String insertStr = \INTO yg (no,name,jbgz,jt)VALUES('\()+\
sql.executeUpdate(insertStr);
JOptionPane.showMessageDialog(this, \录入成功!\
}
catch(SQLException e2){
JOptionPane.showMessageDialog(this, \输入的数值有误\ }
tf1.setText(\Text(\
chaxun(); }
else{
JOptionPane.showMessageDialog(this, \权限不足,不能操作!\
tf1.setText(\Text(\ }
con.close(); sql.close(); }
catch (SQLException e1) {
JOptionPane.showMessageDialog(this, \录入失败!\ } }
if (b2.equals(e.getSource())) {// 修改 Connection con; Statement sql; ResultSet rs; try {
Class.forName(\ } catch (ClassNotFoundException e1) { System.out.println(\ }
13