【发布时间】:2015-11-02 18:54:32
【问题描述】:
我在网上冲浪,并不搜索我需要的东西。所以请你帮助我。 当我尝试在 Eclipse 中执行此 SQL 语句时
private final String INSERT_ = "INSERT INTO department VALUES (?, ?, ?)";
我有下一个错误:您的 SQL 语法有错误;检查与您的 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!");
}
提前致谢!
【问题讨论】:
-
I surf the net and don't search what I need.是的,我在 SO 上注意到了很多。