[英]Data not inserted into database table with PreparedStatement
I have a bit of a problem, Im trying to insert a row into a database table, everything looks like it's working fine.My debugger doesn't find anything and neither does my catch(SQLException) but nothing is saved to database. 我有一个问题,我试图在数据库表中插入一行,一切看起来都很好,我的调试器找不到任何东西,我的catch(SQLException)也没有,但是什么都没有保存到数据库中。
This is my insert code: 这是我的插入代码:
String query = "INSERT INTO files_authorised(auth_id,level,notify,level_user,approval_status) VALUES(?,?,?,?,?)";
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, auth_id);
stmt.setInt(2, level);
stmt.setString(3, notify);
stmt.setInt(4, level_user);
stmt.setString(5, approval_status);
System.out.println(query);
stmt.executeUpdate();
The values being send as parameters are fine, I printed them and the are exactly as I want them. 作为参数发送的值很好,我将它们打印出来,并且完全符合我的要求。
Thanks in advance. 提前致谢。 If you need any further info just comment.
如果您需要更多信息,请评论。
The problem was that i didn't insert 问题是我没有插入
con.commit();
This was the first time this problem has occurred while inserting into a database. 这是在插入数据库时第一次发生此问题。
Answer by StanislavL Thansks StanislavL 斯坦尼斯拉夫·斯坦尼斯·斯坦尼斯拉夫的回答
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.