import java.sql.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*; class dbConnection
{ public static Connection getConnection()
{
  Connection con;
  try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Xiaoyuanka");
return con;
  }catch(ClassNotFoundException e)
      { JOptionPane.showMessageDialog(null,"无法找到!");}       return null;    }
}class User
{
public String id;
public String password;
public boolean CheckUser(String ID,String pw)
{
Statement stmt;
Connection conn;
try
{
conn=DBConnection.getConnection();
stmt=conn.createStatement();
ResultSet rs=stmt.execute("select * from Student");
if(rs.next())
{
id=rs.getString("id");
password=rs.getString("password");
stmt.close();
conn.close();
}
}catch(SQLException e){System.out.println(e.getMessage());}
if(ID.equals(id)&&pw.equals(password))
return true;
else
return false;
}
}public class Text1 extends Applet implements ActionListener
{
Label n1,n2;
TextField txt1,txt2;
Button btn;
User user;
public void init()
{
user=new User();
n1=new Label("姓名:");
n2=new Label("密码:");
txt1=new TextField(8);
txt2=new TextField(8);
add(n1);add(txt1);
add(n2);add(txt2);
add(btn);
btn.addActiontListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(user.CheckUser(txt1.getText(),txt2.getText()))
JOptionPane.showMessageDialog(null,"yes");
else
JOptionPane.showMessageDialog(null,"NO");
}
}数据库中只有一张表,名字为Student  属性有 id(主健),name,address,grade,password,这些都是字符串类型,还有属性 money 货贝型的(数据库用的是ACCESS)
请大家帮我改下,谢谢了~~