19

I use jOOQ to query/insert/update data from/into a table.

Is there a way to see the SQL statements that JOOQ executes?

assylias
  • 321,522
  • 82
  • 660
  • 783
user1455204
  • 199
  • 1
  • 1
  • 3
  • 2
    possible duplicate of [How can we profile JOOQ statements for speed](http://stackoverflow.com/questions/8561317/how-can-we-profile-jooq-statements-for-speed) – assylias Jan 29 '14 at 12:15

2 Answers2

28

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
Maurizio Lo Bosco
  • 1,199
  • 16
  • 17
7

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:

How can we profile JOOQ statements for speed

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509