Can not issue data manipulation statements with executeQuery()

483 views
Skip to first unread message

Shimun Matić

unread,
Dec 2, 2020, 11:21:24 AM12/2/20
to jOOQ User Group
Hello.

I've been using JOOQ with Spring for a few months now and everything was great until I upgraded the project to the latest Spring Boot version. (2.3.5 RELEASE to 2.4.0)

With the latest Spring release comes the latest JOOQ release (3.13.5 to 3.14.4)

I am facing the problem when I try to store a record. (Exception at the end of the post)
Important thing to note is that this only happens when I am not using autoconfiguration.
With JooqAutoConfiguration class enabled, everything works as expected.
Another important factor is the database. I am using MariaDB, tested with 10.1.38 and 10.5.x (docker latest).

What I had tried:
1. Downgraded JOOQ version to 3.13.x - worked as expected
2. Downgraded JOOQ version to 3.14.0 - same error
3. Used different DB (postgres) - worked as expected

So it seems to me that there has been some change in 3.14.x that broke the simplest (manual) DSL configuration for MariaDB (This configuration works with older version and with postgres).  

I have made a simple project which showcases the problem. 

If you want to test the project:
1. jdbc url (pom and application.yml) has to be changed to point to your db 
(or you can create test db with docker, this way URL stays the same:
docker run --name mariadb -e MYSQL_DATABASE=db_test -e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mariadb:latest)
2. change java version to the one you have, 15 was used. (tested on JDK 11 too)

Does anybody know if I am missing something in the DSL configuration or is this a bug?

Thanks,
Shimun


Shimun Matić

unread,
Dec 2, 2020, 11:22:07 AM12/2/20
to jOOQ User Group
org.jooq.exception.DataAccessException: SQL [insert into `db_test`.`person` (`firstname`, `lastname`, `username`, `email`) values (?, ?, ?, ?) returning `id`]; Can not issue data manipulation statements with executeQuery().

at org.jooq_3.14.4.MARIADB.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:2904)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:757)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:389)
at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:218)
at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:183)
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:131)
at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:179)
at org.jooq.impl.UpdatableRecordImpl.store0(UpdatableRecordImpl.java:219)
at org.jooq.impl.UpdatableRecordImpl.access$000(UpdatableRecordImpl.java:89)
at org.jooq.impl.UpdatableRecordImpl$1.operate(UpdatableRecordImpl.java:145)
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:131)
at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:141)
at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:133)
at com.example.jooqtest.JooqTestApplicationTests.testSavingToMariaDb(JooqTestApplicationTests.java:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.StatementImpl.checkForDml(StatementImpl.java:367)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:962)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
at org.jooq.tools.jdbc.DefaultPreparedStatement.executeQuery(DefaultPreparedStatement.java:99)
at org.jooq.impl.AbstractDMLQuery.executeReturningQuery(AbstractDMLQuery.java:1230)
at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:1039)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:375)
... 76 more

Lukas Eder

unread,
Dec 2, 2020, 11:45:38 AM12/2/20
to jOOQ User Group
Hi Shimun,

Thank you very much for your message. I suspect that the Spring Boot autoconfiguration still works for you because that Spring Boot version you're using still depends on a jOOQ 3.13 version.

Starting from jOOQ 3.13, the minimum supported MariaDB version of the jOOQ Open Source Edition was 10.5. Since we've increased this requirement, we've started supporting newer MariaDB features, including the very useful INSERT .. RETURNING support in jOOQ 3.14:

The jOOQ Professional and Enterprise Editions continue to support MariaDB versions 10.0 - 10.5 from jOOQ 3.13 onwards. For more details about supported RDBMS versions, please refer to this page here:

Please let me know if you have any additional questions, and I'll be very happy to help.
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/b4dbbfac-940f-41cd-8f6a-d69b76f06cafn%40googlegroups.com.

Shimun Matić

unread,
Dec 3, 2020, 4:16:44 AM12/3/20
to jOOQ User Group

Hi Lukas,

Thank you very much for responding so quick.

So I checked which version of JOOQ comes with spring-boot-starter-jooq:2.4.0. It is 3.14.3. source
Since I tried the latest MariaDB version I don't think it has something to do with compatibility or right dialect.
At the beginning I thought that it had something to do with Spring, so I wanted to make sure.
That is why I removed Spring completely from test project I tried it with the most minimal configuration. 
Results are the same:
It works as expected with 3.13.6. Same issue with 3.14.4.
Since the new JOOQ version works with Spring Autoconfiguration I have to conclude that there is something missing in my configuration for v3.14.x, something new I have to configure with newer JOOQ versions with MariaDB.
Project sample: Github
Do you have any idea what that could be?

Thanks,
Shimun

Lukas Eder

unread,
Dec 3, 2020, 4:47:37 AM12/3/20
to jOOQ User Group
On Thu, Dec 3, 2020 at 10:16 AM Shimun Matić <shimun...@gmail.com> wrote:

Hi Lukas,

Thank you very much for responding so quick.

So I checked which version of JOOQ comes with spring-boot-starter-jooq:2.4.0. It is 3.14.3. source

What does calling "mvn dependency:tree" say about the various versions on your classpath?
 
Since I tried the latest MariaDB version I don't think it has something to do with compatibility or right dialect.
At the beginning I thought that it had something to do with Spring, so I wanted to make sure.
That is why I removed Spring completely from test project I tried it with the most minimal configuration. 
Results are the same:
It works as expected with 3.13.6. Same issue with 3.14.4.

But that's what I'm saying. With jOOQ 3.13, we didn't produce the RETURNING clause in INSERT statements, when fetching generated keys. We called JDBC's Statement.getGeneratedKeys() instead. With 3.14, we started generating the much more powerful RETURNING clause.

Your stack trace shows that the RETURNING clause is being generated in jOOQ 3.14.4.
 
Since the new JOOQ version works with Spring Autoconfiguration I have to conclude that there is something missing in my configuration for v3.14.x, something new I have to configure with newer JOOQ versions with MariaDB.
Project sample: Github

That project sample doesn't seem to use Spring, though?
 
Do you have any idea what that could be?

Irrespective of why you have 3.13 or 3.14 on your classpath, these versions of the jOOQ Open Source Edition do not support MariaDB 10.4 or less. I recommend using the jOOQ Professional Edition for MariaDB 10.4 support. Here's how to do that with maven:

Shimun Matić

unread,
Dec 3, 2020, 5:28:47 AM12/3/20
to jOOQ User Group
Like I said, I am testing it with the latest MariaDB version 10.5.8 and the problem is still there.
I have removed Spring from the project as I wanted to remove Spring as a factor.
That is why I have created this plain Java project. To test JOOQ without Spring "interference"

Lukas Eder

unread,
Dec 3, 2020, 5:54:50 AM12/3/20
to jOOQ User Group
On Thu, Dec 3, 2020 at 11:28 AM Shimun Matić <shimun...@gmail.com> wrote:
Like I said, I am testing it with the latest MariaDB version 10.5.8 and the problem is still there.

I see, my bad. I thought the problem appeared only when you tested things with 10.1.38

What's the reason you're using the MySQL JDBC driver, and not org.mariadb.jdbc:mariadb-java-client?

Shimun Matić

unread,
Dec 3, 2020, 6:12:32 AM12/3/20
to jOOQ User Group
Wow, I did not notice that.
It works now, thank you and sorry for wasting your time.

Lukas Eder

unread,
Dec 3, 2020, 6:51:10 AM12/3/20
to jOOQ User Group
I'm glad it helped :)

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages