我有我的 insert.sql 文件和超过 10 行的命令 INSERT INTO
我尝试使用 jooq 插入它
String insertSql = mustacheEngine.getMustacheSource("insert.sql");
dslContext.execute(insertSql);
但我收到此错误
Cannot insert multiple commands into a prepared statement
我该如何解决这个问题?我使用真实的数据库和连接
最佳答案
Vertica 不支持准备好的语句中的多个语句,默认情况下 jOOQ 始终在幕后创建 JDBC PreparedStatement
,请参阅:https://www.jooq.org/doc/latest/manual/sql-execution/statement-type/
但是,您可以告诉 jOOQ 使用静态语句(JDBC Statement
),which should support multiple statements in Vertica .
DSLContext ctx = DSL.using(connection, SQLDialect.VERTICA,
new Settings().withStatementType(StatementType.STATIC_STATEMENT));
ctx.execute(insertSql);
关于java - jooq 从 sql 文件插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62410044/