Java JTextfieldとPasswordfieldでパスワードとユーザー名を取得できないようですが、ユーザー入力を比較し、ユーザー名とパスワードがデータベースに格納されているかどうかを確認していますもしそうなら、彼らはログインしますが、私のパスワードフィールドのgetText()は廃止されました。どうすればこの問題を解決できますか?Java JDBCログインフォーム
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import javax.swing.JOptionPane;
public class Login extends JFrame {
private JLabel nameLabel;
private JLabel passwordLabel;
private JTextField nameText;
private JPasswordField passwordField;
private JButton submitButton;
Connection conn = null;
public Login(){
super("Log in!");
setLayout(new FlowLayout());
setVisible(true);
setSize(178,190);
setDefaultCloseOperation(EXIT_ON_CLOSE);
nameLabel = new JLabel("User ID: ");
add(nameLabel);
nameText = new JTextField(10);
add(nameText);
passwordLabel = new JLabel("Password: ");
add(passwordLabel);
passwordField = new JPasswordField(10);
add(passwordField);
submitButton = new JButton("Submit");
add(submitButton);
ButtonHandler handler = new ButtonHandler();
submitButton.addActionListener(handler);
}
private class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
String user = nameText.getText();
String pass = passwordField.getText();
try{
Jdbc test = new Jdbc();
conn = test.dbConn();
String query = "SELECT employee_ID,employee_password FROM user where ='"+user+"'";
}catch(Exception eee){
eee.printStackTrace();
}
}
}
}
これはあなたを助けるかもしれない:http://docs.oracle.com/javase/tutorial/uiswing/components/passwordfield.html –