← All guides
JAVA & SPRING BOOT

How to Print & Bind Hibernate, MyBatis, EclipseLink & jOOQ SQL Logs Into Runnable SQL

Find the right SQL and parameter logging switches across Java persistence frameworks, then reconstruct a readable query for your database. Keep the raw log context and review values before running anything.

HIBERNATE 6 / 7orm.jdbc.bind
MYBATISStdOutImpl
ECLIPSELINK · jOOQParameters · LoggerListener DEBUG
INSTANT BINDING100% Local Browser Tool

Why show-sql=true is not enough for production debugging

Hibernate's show_sql option writes generated SQL directly to the console. That can be useful for a quick look, but a prepared statement may still appear with ? placeholders while bind values are logged separately. If the SQL and bind events are mixed with Spring Boot timestamps, thread names, and unrelated application messages, manually pairing them becomes error-prone.

Use the framework's logger categories when you need structured output, and capture the SQL statement plus the corresponding bind lines from the same execution. A parameter binder can help turn those two pieces into a readable SQL literal view; it does not reproduce every JDBC type, session setting, or database-side behavior.

Log values can contain sensitive data.

TRACE logging may expose names, tokens, identifiers, or personal data. Enable it only where appropriate, restrict access and retention, and redact sensitive values before sharing logs.

Exact logging configs across Java persistence frameworks

Spring Boot routes framework loggers through the logging implementation on your classpath. Add the relevant categories to application.yml, or configure the equivalent logger names in Logback or Log4j2. Start with a narrow package and raise verbosity only for the debugging session.

Hibernate 6 / 7 and Hibernate 5

Hibernate 6 and 7 use org.hibernate.orm.jdbc.bind for JDBC parameter binding. Hibernate 5 uses the older org.hibernate.type.descriptor.sql.BasicBinder category. This package change is a common reason an old TRACE setting stops showing bind values after an upgrade.

logging:
  level:
    org.hibernate.SQL: DEBUG
    org.hibernate.orm.jdbc.bind: TRACE  # Hibernate 6 / 7
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE  # Hibernate 5

The SQL logger prints statements; the bind logger prints values and types. If one appears without the other, check the Hibernate major version and the active logging backend.

MyBatis and MyBatis-Plus

MyBatis can use the application's normal logging facade, or its STDOUT_LOGGING implementation for a quick local check. In Spring Boot, enabling DEBUG for the mapper namespace or mapped statement is usually easier to control. Typical output pairs Preparing: with Parameters:; MyBatis-Plus follows the same MyBatis logging setup.

mybatis:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

For application logging, prefer a logger configuration such as logging.level.com.example.mapper: DEBUG and keep the mapper namespace aligned with your actual package.

Spring JdbcTemplate

Spring documents SQL issued by JdbcTemplate at DEBUG under org.springframework.jdbc.core.JdbcTemplate. Parameter-setting details may come from org.springframework.jdbc.core.StatementCreatorUtils at TRACE, depending on the path and Spring version.

logging:
  level:
    org.springframework.jdbc.core.JdbcTemplate: DEBUG
    org.springframework.jdbc.core.StatementCreatorUtils: TRACE

EclipseLink (Jakarta Persistence)

For EclipseLink, configure its SQL logging level and parameter output in the persistence unit. FINE-level SQL logging includes bind parameters by default; eclipselink.logging.parameters can explicitly enable or disable them.

<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>

Depending on the logger and version, the output often includes a SQL line followed by ordered lines such as bind => [value]. Keep the sequence together so values are associated with the correct query.

jOOQ

jOOQ's ExecuteListener extension point can observe render, prepare, bind, execute, and fetch events. Its default LoggerListener can emit an “Executing query” line and a “with bind values” rendering. In Spring Boot, DEBUG for org.jooq.tools.LoggerListener is a common way to inspect that output.

logging:
  level:
    org.jooq.tools.LoggerListener: DEBUG

Use the rendered query with values only as a debugging representation. It may not be byte-for-byte equivalent to the exact wire-level statement or preserve every JDBC-specific value type.

Need to run that messy console SQL in DataGrip or DBeaver right now?

Paste your raw Hibernate, MyBatis, JdbcTemplate, EclipseLink, or jOOQ logs into our free Java SQL Log Parameter Binder. It supports MySQL, PostgreSQL, Oracle, and SQL Server, 100% in-browser with zero server uploads.

Open SQL Log Binder →

ORM log syntax and database dialect cheat sheet

Frameworks differ in how they show parameter order and type information. The binder recognizes common patterns, but logs vary with framework versions, custom appenders, and application prefixes.

FrameworkTypical log cluesDatabase rendering notes
Hibernate 6 / 7org.hibernate.SQL plus indexed orm.jdbc.bind eventsOracle dates may need TO_DATE/TO_TIMESTAMP; check fractional seconds and timezone.
Hibernate 5BasicBinder parameter indexes and JDBC typesMySQL and PostgreSQL accept quoted strings and date literals, subject to session settings.
MyBatis / PlusPreparing: and typed Parameters: listQuoted values and comma-containing strings require careful parsing; custom type handlers can differ.
Spring JdbcTemplateExecuting prepared SQL statement and parameter-setting tracesSQL Server strings may use N'…'; booleans and temporal literals are dialect-dependent.
EclipseLink[EL Fine]: sql: and ordered bind => messagesOracle commonly uses 1/0 for boolean-like values; verify column types.
jOOQExecuting query and with bind valuesUse jOOQ's rendered query if present, then check quoting and dialect-specific syntax.
Literal SQL is for inspection.

In application code, keep prepared statements and bind parameters. Interpolated values are useful for local debugging but can change semantics when casts, locale, timezone, binary values, arrays, or vendor-specific types are involved.

Why use a client-side binder instead of adding P6Spy?

P6Spy and datasource-proxy instrument JDBC calls and can provide richer runtime data such as execution timing and connection context. They are useful when a team needs persistent observability or tests around SQL behavior, but they also require dependency and configuration changes and can expose bound values in logs.

A browser-side binder solves a smaller, ad-hoc task: reconstruct a query from logs you already captured, without changing the running application's dependencies or deployment configuration. It cannot show execution timing, database session state, or the exact binary protocol. Choose the approach that fits the debugging question, and treat both log output and copied SQL as sensitive.

Java SQL logging and parameter binding FAQ

Why is BasicBinder not working in Spring Boot 3?

Spring Boot 3 commonly uses Hibernate 6, where JDBC bind messages use org.hibernate.orm.jdbc.bind. BasicBinder is the older Hibernate 5 category. Confirm the resolved Hibernate version before changing logger names.

How do I print SQL with parameters in EclipseLink?

Set the EclipseLink SQL logging level to FINE and ensure eclipselink.logging.parameters=true. The logger can show SQL and ordered bind output; exact formatting depends on EclipseLink version and logging backend.

How do I extract runnable SQL from jOOQ debug logs?

When the log contains a “with bind values” rendering, use that line as the starting point. Otherwise pair the rendered statement with the bind events captured by a configured ExecuteListener; inspect dialect-specific quoting before execution.

How should Oracle TO_TIMESTAMP and boolean 1/0 values be handled?

Oracle timestamp literals need a format that matches the actual text and precision, and boolean-like values may be represented as 1 or 0 depending on the column and schema. Verify the target column types and timezone semantics rather than assuming a universal conversion.

Is it safe to enable parameter logs in production?

It can expose personal data, credentials, tokens, or business records. Keep verbose parameter logging narrowly scoped, time-limited, access-controlled, and redacted where possible. Remove sensitive values before sharing logs.

Official documentation