I use jOOQ to query/insert/update data from/into a table.
Is there a way to see the SQL statements that JOOQ executes?
I use jOOQ to query/insert/update data from/into a table.
Is there a way to see the SQL statements that JOOQ executes?
Look for your log configuration file (or create one) and set the log level of the class org.jooq.tools.LoggerListener
as debug
or trace
, e.g. into log4j.properties
.
In spring you can set the log level DEBUG into your application.properties this way
logging.level.org.jooq.tools.LoggerListener=DEBUG
For the following query
create.select(BOOK.ID, BOOK.TITLE).from(BOOK).orderBy(BOOK.ID).limit(1, 2).fetch();
you should get a log like
Executing query : select "BOOK"."ID", "BOOK"."TITLE" from "BOOK" order by "BOOK"."ID" asc limit ? offset ?
-> with bind values : select "BOOK"."ID", "BOOK"."TITLE" from "BOOK" order by "BOOK"."ID" asc limit 2 offset 1
There is a blog article on the jOOQ blog describing how to debug-log the generated SQL:
https://blog.jooq.org/debug-logging-sql-with-jooq/
Note, this was also dealt with on this Stack Overflow question here: