Nhờ mọi người xem em cái dòng insert into có vấn đề gì không ạ.Sao em không thêm vào csdl dc ạ
public static void add() {
Connection mycon = null;
Statement mySta = null;
ResultSet result = null;
try {
System.out.println("Nhập username: ");
String userName = new Scanner(System.in).nextLine();
System.out.println("Nhập passwword: ");
String pass = new Scanner(System.in).nextLine();
mycon = DriverManager.getConnection("jdbc:mysql://localhost:3306/qldangnhap", "root", "xuanthang86");
mySta = mycon.createStatement();
//String str = "INSERT INTO `qldangnhap`.`dangnhap` (`UserName`, `Password`) VALUES ('aphgaldppka', 'papapapapap')";
String str = "INSERT INTO `qldangnhap`.`dangnhap` (`UserName`, `Password`) VALUES(`" + userName + "`,`" + pass + "`)";
mySta.executeUpdate(str);
System.out.println("Them thanh cong");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (result != null) {
result.close();
}
if (mySta != null) {
mySta.close();
}
if (mycon != null) {
mycon.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}