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.
1 Answers
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.
-
how about dbutils? – blackdog Dec 02 '16 at 09:25
-
See my edit, dbutils won't help you here. – Kayaman Dec 02 '16 at 10:14