```
import java.awt.;
import java.awt.event.;
import java.sql.*;
import javax.swing.*;
public class login extends JFrame{
connection c=new connection();
Connection cc=c.getConnect();
public login(){
this.setTitle("登入界面");
this.setBounds(600,400,300,200);
final JTextField text1;
final JPasswordField text2;
JButton button1;
setLayout(new GridLayout(5,1));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
add(new JLabel("账户名"));
text1=new JTextField(10);
add(text1);
add(new JLabel("密码"));
text2=new JPasswordField(10);
add(text2);
button1=new JButton("登入");
add(button1);
button1.addActionListener(new ActionListener(){
PreparedStatement ps=null;
public void actionPerformed(ActionEvent e){
try {
String username1=text1.getText();
String password1=text2.getText();
String sql="select * from admin where username = ? and password = ?";
PreparedStatement ps=cc.prepareStatement(sql);
ps.setString(1,username1);
ps.setString(2,password1);
ResultSet rs=ps.executeQuery();
if(rs.next()){
admin ad=new admin();
ad.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"用户名或密码错误");
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
}
}
```数据库连接上了PreparedStatement ps=cc.prepareStatement(sql);这句话为啥报错啊