Re-assemble Preparing / Parameters lines into executable SQL.

Switch tool
Paste MyBatis log lines (with Preparing/Parameters). Multiple groups are auto-detected. Each group outputs one executable SQL.
MyBatis log input
Executable SQL0 group(s)

How to use

Purpose

MyBatis log SQL restorer. Combines two-line log output (Preparing: line + Parameters: line) into a runnable real SQL. Replaces ? placeholders in parameter order with actual values, correctly handling string quoting, date format, null values, and special-character escaping. Common for MyBatis / MyBatis-Plus slow SQL triage, production bug reproduction, SQL performance testing. All processing runs locally; sensitive DB content does not leave the browser.

Steps

  1. Paste MyBatis log (with ==> Preparing: and ==> Parameters: lines)
  2. Tool auto-detects the SQL template and parameter list
  3. Replaces ? in order with parameter values (strings auto-quoted)
  4. Date/time parameters output in SQL standard (「2026-01-01 12:00:00」)
  5. Right pane shows the runnable complete SQL
  6. Pair with sql-formatter for readability
  7. Batch: multiple SQL in the log restored at once
  8. Export .sql file for DBeaver / Navicat execution

FAQ

Log Parameters shows null(Integer) — what to do?
MyBatis Parameters line format: value1(Type1), value2(Type2). Tool recognizes null(Integer) and replaces with NULL (unquoted). Note: "null" string vs NULL differ semantically — type annotation matters. If you copied only the SQL without types, the tool falls back to a heuristic (looks-like-number → Integer, else String).
IN (?, ?, ?, ?, ?) — how is it handled?
Multiple ?s in IN are replaced in order; Parameters line carries N values. MyBatis foreach generates IN (?, ?, ?, ...) with N ?s. The tool maps them in order, producing IN ('a', 'b', 'c', 'd', 'e').
Does LIKE '%xxx%' wildcards break?
No. Wildcard characters (% _) inside LIKE parameters are preserved (they belong to LIKE semantics). e.g., LIKE '%' || #{keyword} || '%' with keyword "tom" → LIKE '%tom%'.
Date/time parameter format wrong?
The Parameters line typically uses Java’s LocalDateTime.toString() (2026-01-01T12:00:00). Tool converts to SQL standard: 2026-01-01 12:00:00 (T → space). MySQL and PostgreSQL accept both; SQL standard is more cross-database.
Why does my log have no Parameters line?
MyBatis default logs only the SQL template, not parameters. Enable: log4j/logback `<logger name="com.your.mapper" level="DEBUG"/>` or application.properties: logging.level.com.your.mapper=debug. In production keep at INFO (parameters bloat logs); switch to DEBUG temporarily for triage.

Use cases

  • Slow SQL triage: take MyBatis log from slow log, restore, run EXPLAIN
  • Production bug reproduction: user reports → restore SQL → reproduce in test DB
  • Performance test: batch-run production SQL in test DB to measure throughput
  • Code Review: see actual SQL output from complex dynamic SQL (foreach/if/where)
  • Learning: see what MyBatis dynamic SQL actually produces

Use cases

Slow SQL triage, production reproduction, SQL perf testing, dynamic SQL review, MyBatis learning. Java backend, DBA, perf engineer. Batch processing, smart placeholder detection, date format normalization, null type detection are the differentiators.