2

I reviewed the source code, bug I can't find anything about show sql. Is that possible or I have to log them by myself? I only find some log in HikariConfig, HikariPool, HikariDataSource. None of them can help me.

blackdog
  • 2,007
  • 3
  • 25
  • 43

1 Answers1

-1

HikariCP is a connection pool, it doesn't have much to do with executing SQL. If you want to see the SQL, see the documentation for your ORM (such as Hibernate) or JDBC driver.

If you are using direct JDBC, then there's not much hope for automatic logging. Depending on the database / driver being used, you might get a nice representation out of PreparedStatement.toString() as described in this answer: Get query from java.sql.PreparedStatement

The database itself is of course capable of logging queries, so that can also be a solution unless you need to log them on the Java side. There's also the possibility of logging the network traffic to the database, but that can be tricky and has the same problem as with the database query log.

Finally you could try to achieve some wrapper/proxy solution, which would automate the logging. But I suspect that this has some issues since I can't think off the top of my head of any existing library that would do this.

Community
  • 1
  • 1
Kayaman
  • 72,141
  • 5
  • 83
  • 121