简体   繁体   English

(?,?,?) 附近的 SQL 语法错误

[英]error in your SQL syntax near (?,?,?)

I surf the net and don't search what I need.我上网,不搜索我需要的东西。 So please you help me.所以请你帮帮我。 When I try to execute this SQL statement in Eclipse当我尝试在 Eclipse 中执行此 SQL 语句时

private final String INSERT_ = "INSERT INTO department VALUES (?, ?, ?)";

I have next error:You have an error in your SQL syntax;我有下一个错误:您的 SQL 语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?, ?)' at line 1 This is my code检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的“?, ?, ?)”附近使用的正确语法这是我的代码

public void insert(int id, String name, String description) throws SQLException
{
    Department result = null;
    Connection conn = ConnectionManager.getConnection();
    PreparedStatement stmt = conn.prepareStatement(INSERT_);
    stmt.setInt(1, id);
    stmt.setString(2, name);
    stmt.setString(3, description);
    stmt.executeUpdate(INSERT_);
    System.out.println("Record is inserted into table!");
}

Thanks in advance!提前致谢!

You shouldn't pass the SQL String to executeUpdate , since your PreparedStatement was already initialized with the SQL String + the parameters. 您不应该将SQL String传递给executeUpdate ,因为您的PreparedStatement已经使用SQL String +参数初始化。

Change 更改

stmt.executeUpdate(INSERT_);

to

stmt.executeUpdate();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您的SQL语法附近的错误 - error in your SQL syntax near 您的 SQL 语法有错误; 在第 1 行的“Type='1”附近 - 我无法编写正确的 SQL 查询 - You have an error in your SQL syntax; near 'Type='1'' at line 1 - I cant write correct SQL query 您的SQL语法有错误; 查看与您的MySQL服务器版本对应的手册,以便在第1行使用“98”附近的正确语法 - 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 '98)' at line 1 您的SQL语法有误; 查看与您的MySQL服务器版本相对应的手册以获取正确的语法,以在'order'附近使用 - 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 'order SQL 语法错误; 检查与您的 MySQL 服务器版本相对应的手册,以了解在“? 或电话=? 在第 1 行 - error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? or tel=?' at line 1 您的SQL语法有错误; 检查与您的MySQL服务器版本相对应的手册,以在第1行的'null'附近使用正确的语法 - 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 'null' at line 1 您的SQL语法有误; 检查与您的MariaDB服务器版本相对应的手册,以找到在第1行中的“”附近使用的正确语法 - you have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' ' in Line 1 您的SQL语法有误; 检查与您的MariaDB服务器版本相对应的手册,以获取在'?'附近使用的正确语法。 在第1行 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1 desc附近的SQL语法错误 - SQL syntax error near desc 您的SQL语法有误; …在第1行的[[C @ f8d6792]附近 - You have an error in your SQL syntax; … near '[C@f8d6792'' at line 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM