I have my insert.sql file and over 10 rows inside with command INSERT INTO
And I try to insert it using 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/
However, you can tell jOOQ to use static statements instead (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);