简体   繁体   English

jooq 从 sql 文件插入

[英]jooq insert from sql file

I have my insert.sql file and over 10 rows inside with command INSERT INTO我有我的 insert.sql 文件和超过 10 行的命令INSERT INTO

And I try to insert it using jooq我尝试使用 jooq 插入它

String insertSql = mustacheEngine.getMustacheSource("insert.sql");
dslContext.execute(insertSql);

But I get this error但我得到这个错误

Cannot insert multiple commands into a prepared statement

How can I fix it?我该如何解决? I use real database and connection我使用真实的数据库和连接

Vertica doesn't support multiple statements in a prepared statement, and jOOQ by default always creates a JDBC PreparedStatement behind the scenes, see: https://www.jooq.org/doc/latest/manual/sql-execution/statement-type/ Vertica 不支持一个prepared statement 中的多个statement,jOOQ 默认总是在后台创建一个JDBC PreparedStatement ,参见: https://www.jooq.org/doc/latest/manual/sql-execution/statement-type /

However, you can tell jOOQ to use static statements instead (JDBC Statement ), which should support multiple statements in Vertica .但是,您可以告诉 jOOQ 使用 static 语句代替(JDBC Statement ), 它应该支持 Vertica 中的多个语句

DSLContext ctx = DSL.using(connection, SQLDialect.VERTICA,
  new Settings().withStatementType(StatementType.STATIC_STATEMENT));
ctx.execute(insertSql);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM