I am doing a log in application in which users should be able to sign in. But I am getting this error:
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "Name": syntax error)
This is how my code looks like:
saveTButton.addEventHandler(ActionEvent.ACTION, (e)-> {
try
{
String query = "insert into TeachersInfo (First Name,Last Name,UserName,Password) values (?,?,?,?)";
PreparedStatement pst = connectionUsers.prepareStatement(query);
//First question mark = 1, second = 2, etc.
pst.setString(1,nameSignupTTextField.getText());
pst.setString(2,lastnameSignupTTextField.getText());
pst.setString(3,usernameSignupTTextField.getText());
pst.setString(4,passwordSignupTTextField.getText());
pst.execute();
System.out.println("Data saved");
//after executing the query this lines will close the connection with the database
pst.close();
}
catch(Exception a)
{
System.out.println(a);
}
});
The code should save the info entered by the user in the database. I have no idea what is the problem so I would really appreciate the help. Thank you in advance..
Aucun commentaire:
Enregistrer un commentaire