0

以前我正在使用语句,但我需要使用 JOOQ 转换它

  Statement dboSt = null; 

dboSt = dboConn.createStatement(); 

我需要知道如何在 JOOQ 中更改我的以下行。

dboSt.executeUpdate("alter login \"" + UserId + "\" with password='" + NewPassword + "'");

dboSt.executeUpdate("alter login \"" + UserId + "\" with password='" + NewPassword + "' old_password='" + OldPassword
                                + "'");

有什么办法可以转换吗?

4

1 回答 1

0

jOOQ 还不支持类型安全的 DDL。它已经在路线图上一段时间了:#883

同时,您可以直接使用 jOOQ 执行纯 SQL 语句,如下所示:

DSLContext ctx = DSL.using(configuration);

// As before, manually inlining arguments:
ctx.execute("alter login \""+UserId+"\" with password='"+NewPassword+"'");

// Better, letting jOOQ do the string escaping for you, preventing
// syntax errors and SQL injection vulnerabilities:
ctx.execute("alter login {0} with password = {1}",
    DSL.name(UserId),       // org.jooq.Name is rendered with quotes in most DBs
    DSL.inline(NewPassword) // org.jooq.Param is inlined as a (string) literal
);
于 2013-10-16T11:32:34.897 回答