I want to know what exactly sql query is processed by jdbi sql api for debugging purposes. My interface class is following
public inteface myinteface{
@SqlQuery("select :c1 from tablename where cond = :cd")
String returnMeValue(@Bind("c1") String c1, @Bind("cd") Integer cd);
}
and later called in another class as String result = myinterfaceclassobject.returnMeValue("Name",1);
I am not getting expected answer so I want to see what actually going to the sql query. So is there any method to get the final processed query?
You can log the sql by writing SqlCustomizer.
Just include this annotation and use this in SqlObject. In your case use this annotation like this,
If you use custom loggers for logging, then beforeExecution method.
It's much easier to use something like log4jdbc, using Manikandan's method also slows down your code quite a bit.
However if you would still like to use it and your project language level doesn't support lambdas, you can use the following modification:
However stmt.toString() is not guaranteed to return the SQL statement, it depends on the implementation. This will not work for SQLite.