idea连接数据库报错java.sql.SQLException: You have an error in your SQL syntax;

报错:

java.sql.SQLException: 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 ''username',password,email) values('ww','admin','[email protected]')' at line 1 Query: insert into t_user('username',password,email) values(?,?,?) Parameters: [ww, admin, [email protected]]

我的错误是在UserDaoImpl包下的实现类saveUser

别在属性名前加引号!!!!!!!!!!!!!!

错误写法:

String sql = "insert into t_user('username','password','email') values(?,?,?)";

正确写法:

String sql = "insert into t_user(username,password,email) values(?,?,?)";

猜你喜欢

转载自blog.csdn.net/m0_62068678/article/details/124049475