如何使用JOOQ改变表格?

时间:2013-10-16 10:27:55

标签: java sql jooq

之前我正在使用声明,但我需要使用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
                                + "'");

有转换它的解决方案吗?

1 个答案:

答案 0 :(得分: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
);