从jdbc中删除MySQL上的表
从 jdbc 删除表时出现问题
我有一个。通过先前准备的语句从多个表中删除记录的 jar
我是这样做的:
-- SQL
delete from tabla_a using tabla_a join tabla_c join tabla_b join tabla_d
where tabla_a.tabla_c_id = tabla_c.id and tabla_c.tabla_b_id = tabla_b.id
and tabla_b.tabla_d_id = tabla_d.id and tabla_d.field = 2;
注意:where (?) is an integer
// Java
conn = DriverManager.getConnection(dsn, user, pass);
stmt = conn.createStatement();
int rows = stmt.executeUpdate(query);
不起作用不会删除任何记录,我直接将 SQL 测试到 MySQL并正常工作。
Problem when deleting tables from jdbc
I have a. jar that deletes records from multiple tables through a previously prepared statement
i did it this way:
-- SQL
delete from tabla_a using tabla_a join tabla_c join tabla_b join tabla_d
where tabla_a.tabla_c_id = tabla_c.id and tabla_c.tabla_b_id = tabla_b.id
and tabla_b.tabla_d_id = tabla_d.id and tabla_d.field = 2;
note: where (?) is an integer
// Java
conn = DriverManager.getConnection(dsn, user, pass);
stmt = conn.createStatement();
int rows = stmt.executeUpdate(query);
does not work does not erase any record, I tested the SQL directly to MySQL and working properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试改用PreparedStatement,并设置参数。沿着这些思路:
Try using a PreparedStatement instead, and set the parameters. Something along these lines: