Menu

1 / 2

Why your MyBatis logs show question marks (and how to turn them into runnable SQL)

DEV Community: java·SongRenShuo·8 days ago
#31ItyLZC
#devtojava#devto#dev#parameters#integer
Long article (1131 words) — no AI summary yet.
Reading 0:00
15s threshold

When something breaks in production, the first thing I do is pull a SQL statement out of the logs and run it against the database myself.

What I actually get is this:

==> Preparing: SELECT id, username, status FROM user WHERE username = ? AND status = ? AND created_at > ? ==> Parameters: tom(String), 1(Integer), 2026-11-20 10:00:00.0(Timestamp)

Enter fullscreen mode

Exit fullscreen mode

Three placeholders, three values, and I have to line them up by hand. Add quotes to the string, reformat the timestamp, strip the type annotations. Doing this once is fine. Doing it fifteen times a day is not.

So I wrote a tool to do it for me. I assumed it would be a weekend of regex.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.