I have the code once I am running it it just gave me error error while validatingjava.lang.NullPointerException
public Login() {
setTitle("Appoinment Booking System :: Login");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBackground(new Color(250, 250, 210));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel userLabel = new JLabel("Username");
JLabel passwordLabel = new JLabel("Password");
userText = new JTextField();
userText.setColumns(10);
passwordText = new JPasswordField();
JLabel lblLogin = new JLabel("Login ");
JLabel lblNewLabel = new JLabel("Appoinment Booking Sytem");
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 25));
lblNewLabel.setForeground(new Color(32, 178, 170));
JButton btnLogin = new JButton("Login");
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("a");
dao = new AppDao();
//System.out.println("b");
char[] tempPass = passwordText.getPassword();
//System.out.println("c");
String password=null;
//System.out.println("D");
password = String.copyValueOf(tempPass);
//System.out.println("e");
if(dao.verifyUser(userText.getText(), password))
{
dispose();
System.out.println("f");
//JOptionPane.showMessageDialog(null, "You have logged in successfully","Success",
// JOptionPane.INFORMATION_MESSAGE);
new Dashboard(userText.getText());
System.out.println("g");
//this.setContentPane(dashboard);
}
else
{
JOptionPane.showMessageDialog(null, "You not logged in successfully","Success",
JOptionPane.INFORMATION_MESSAGE);
System.out.println("h");
}
}
});
Now I have the connector in other class in other class, I really stock to hot to solve this problem it , I have add two three different type of the connector it did not work < I have made some other tips as well to solve this problem as well but it does not work so I need any programmer attention to solve this problem
Connection con;
PreparedStatement pst;
ResultSet rs;
AppDao() {
try {
System.out.println("a");
//MAKE SURE YOU KEEP THE mysql_connector.jar file in java/lib folder
//ALSO SET THE CLASSPATH
String MYSQL_DRIVER_CLASS_NAME = ("com.mysql.jdbc.Driver");
System.out.println("b");
String MYSQL_DB_CONNECTION_PATH = ("jdbc:mysql://localhost:90/booking_appointment");
System.out.println("f");
String MYSQL_DB_USERNAME = "root";
System.out.println("f");
String MYSQL_DB_PASSWORD = "cnwl";
System.out.println("c");
} catch (Exception e) {
System.out.println(e);
}
}
public Connection getConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:90/booking_appointment", "root", "cnwl");
return con;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
return null;
}
}