这是我用来插入表格的代码。
try (Connection conn = DriverManager.getConnection(URL, USER, PASS)) {
DSLContext create = DSL.using(conn, SQLDialect.MYSQL);
uuid = UUID.randomUUID();
create.insertInto(ACCOUNTS, ACCOUNTS.ID, ACCOUNTS.ONESIGNAL_ID, ACCOUNTS.EMAIL, ACCOUNTS.AGE, ACCOUNTS.UUID_L, ACCOUNTS.UUID_M)
.values(userId, oneSignalId, email, (int)age, uuid.getLeastSignificantBits(), uuid.getMostSignificantBits());
} catch (SQLException e) {
e.printStackTrace();
}
它没有插入行,并且它也没有抛出任何错误,所以我不知道哪些错误,也许有经验的人可以帮助我。
此外,是否可以检查插入语句是否成功完成? JooQ似乎比JDBC更复杂,但每个人都告诉我改用JooQ。
感谢。
答案 0 :(得分:1)
您没有致电.execute()
:
try (Connection conn = DriverManager.getConnection(URL, USER, PASS)) {
DSLContext create = DSL.using(conn, SQLDialect.MYSQL);
uuid = UUID.randomUUID();
create.insertInto(ACCOUNTS, ACCOUNTS.ID, ACCOUNTS.ONESIGNAL_ID, ACCOUNTS.EMAIL, ACCOUNTS.AGE, ACCOUNTS.UUID_L, ACCOUNTS.UUID_M)
.values(userId, oneSignalId, email, (int)age, uuid.getLeastSignificantBits(), uuid.getMostSignificantBits())
.execute();
} catch (SQLException e) {
e.printStackTrace();
}