this is the code
PreparedStatement res1 = null;
String insertUser = "INSERT INTO users (uid,firstname,lastname,score) VALUES (" +
this.getFbUid() + "," +
this.getFbFirstName() + "," +
this.getFbLastName() + ",0)";
System.out.println(insertUser);
try
{
res1 = connection.prepareStatement(insertUser);
res1.executeUpdate();
System.out.println("executed query to db with the message" + res1);
}
catch(SQLException e)
{
System.out.println("setUserInDb: " +e.getMessage());
System.out.println("error num: " +e.getErrorCode());
}`
I’m getting error code 1054:
Unknown column ‘Alon’ in ‘field list’ when trying to insert the line “INSERT INTO users (uid,firstname,lastname,score) VALUES (123456,Alon,xyz,0)
In the db I have table users with varchar columns uid, firstname, lastname, and score.
What am I doing wrong?
Alonseems or type varchar should be under'Use Prepared statement rather