import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
//import java.awt.event.WindowAdapter;
//import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.JFrame;
public class HYXXCX implements ActionListener {
private JFrame f;
private JButton B1;
private JLabel L1,L2,L3,L4,L5,L6,L7,L8,L9;
private JTextField T1,T3,T4,T5,T6,T7,T8;
private JPasswordField T2;
String str01,str02;
public HYXXCX(){
f= new JFrame();
f.setTitle("会员信息查询");
Container contentPane = f.getContentPane();
contentPane.setLayout(null);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setBounds(300,130,440,500);
f.setVisible(true);
B1 =new JButton(" 查询 ");
L1=new JLabel("会员号码:");
L2=new JLabel("会员密码:");
L3=new JLabel("身份证号码:");
L4=new JLabel("姓名:");
L5=new JLabel("性别:");
L6=new JLabel("电话:");
L7=new JLabel("住址:");
L8=new JLabel("余额");
L9=new JLabel("查询结果:");
T1 =new JTextField(50);
T2 =new JPasswordField(50);
T3 =new JTextField(50);
T4 =new JTextField(50);
T5 =new JTextField(50);
T6 =new JTextField(50);
T7 =new JTextField(50);
T8 =new JTextField(50);
f.add(L1);
L1.setBounds(40,40,70,25);
f.add(T1);
T1.setBounds(130,40,160,25);
f.add(L2);
L2.setBounds(40,80,70,25);
f.add(T2);
T2.setBounds(130,80,160,25);
f.add(L9);
L9.setBounds(40,120,70,25);
f.add(L3);
L3.setBounds(40,170,70,25);
f.add(T3);
T3.setBounds(130,170,250,25);
f.add(L4);
L4.setBounds(40,210,70,25);
f.add(T4);
T4.setBounds(130,210,250,25);
f.add(L5);
L5.setBounds(40,250,70,25);
f.add(T5);
T5.setBounds(130,250,250,25);
f.add(L6);
L6.setBounds(40,290,70,25);
f.add(T6);
T6.setBounds(130,290,250,25);
f.add(L7);
L7.setBounds(40,330,70,25);
f.add(T7);
T7.setBounds(130,330,250,25);
f.add(L8);
L8.setBounds(40,370,70,25);
f.add(T8);
T8.setBounds(130,370,250,25);
f.add(B1);
B1.setBounds(300,70,80,30);
B1.addActionListener(this);
}
public void actionPerformed (ActionEvent e) {
str01=T1.getText();
str02=T2.getPassword().toString();
String NUM="";
String URL="jdbc:odbc:GMS";
Connection con=null;
Statement sm=null;
ResultSet rs=null;
String id,name;
try
{
Class.forName("com.ms.jdbc.odbc.JdbcOdbcDirver");
}
catch(Exception E)
{
}
try
{//**************************************************************
//出错的地方DirverManager被表了出来,我用的是Eclipse
con=DirverManager.getConnection(URL);
//********************************************************************
sm=con.createStatement();
rs=sm.executeQuery("select * from 计算机 where 帐户=str01 and 密码=str02");
if(!rs.next())
NUM=rs.getString("计算机号码");
}
catch(Exception E)
{
}
finally
{
try
{
rs.close();
sm.close();
con.close();
}
catch(Exception E)
{}
}
}
}