【发布时间】:2017-11-26 08:32:26
【问题描述】:
我不知道为什么这不起作用。我已经在程序的另一部分使用了相同的代码。有什么帮助吗?
try {
PreparedStatement pps;
pps = cn.prepareStatement("INSERT INTO ventas (nombre,precio,cant)
VALUES (?,?,?)");
pps.setString(1, productotxt.getText());
pps.setString(2, preciotxt.getText());
pps.setString(3, cantidadtxt.getText());
pps.executeUpdate();
JOptionPane.showMessageDialog(null, "Registro exitoso!");
} catch (SQLException ex) {
Logger.getLogger(add.class.getName()).log(Level.SEVERE, null, ex);
}
如果有帮助,这是我的 EER 图。
]
【问题讨论】:
-
您可以尝试用 bactick 引用名称:“INSERT INTO ventas (
nombre,precio,cant)VALUES (?,?,?)" -
在字段和表名周围使用反引号`。
-
出现同样的错误:/
-
赛义德,怎么样?我的意思是,我把它放在哪里?
-
INSERT INTO `ventas` (`nombre`,`precio`,`cant`)VALUES (?,?,?)