java.sql.SQLSyntaxErrorException:

Just a New Programmer :

first i created a 2 sql table one is functioning and the other is not the code in my java class is

    try {                           
            PreparedStatement ps1 = con.prepareStatement("INSERT INTO pattable(surname,first,middle,add,contact,email,bdate,genderr) values(?,?,?,?,?,?,?,?);");
            ps1.setString(1, surname);
            ps1.setString(2, first);
            ps1.setString(3, middle);
            ps1.setString(4, add);
            ps1.setString(5, contact);
            ps1.setString(6, email);
            ps1.setString(7, bdate);
            ps1.setString(8, genderr);
            ps1.execute(); 
            ps1.close();
            con.close();
    }
            catch(SQLException e){
                e.printStackTrace();
            }
}

According to console the error might be triggering at line ps1.execute in java with the line "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add,contact,email,bdate,genderr)" please help Thanks for the Reply really need it for case study :)

Swati :

You have one column name add ,this is reserved keyword in mysql .check here you cannot use that as your column name that the reason of error you are getting .

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=416470&siteId=1