MySQL INSERT INTO不起作用,但没有给出错误

时间:2018-12-30 21:36:56

标签: java mysql

我在用Java将行插入MySQL表时遇到麻烦。我不确定是什么问题,因为它没有给出错误。我正在尝试使用以下内容插入行:

String sql = "INSERT INTO users (uuid, authKey, code, scratches) VALUES (?, ?, ?, ?);";
PreparedStatement insertStmt = connection.prepareStatement(sql);
insertStmt.setString(1, uuid);
insertStmt.setString(2, key);
insertStmt.setInt(3, code);
insertStmt.setString(4, getScratchString());

insertStmt.executeUpdate();

表“ users”的创建成功,没有错误,并显示以下内容:

Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS users (uuid VARCHAR(40), authKey VARCHAR(30), code INT(10), scratches VARCHAR(45));");

当尝试在phpmyadmin中插入具有相同更新的行时,它可以正常工作。更新没有给出错误,所以我不知道从哪里开始调试。任何帮助,将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:3)

您必须执行提交事务检查以下代码

[1, 2, 2, 4, 4]
[3, 2, 4, 1, 5, 8]