These days when I am doing business, I occasionally encounter SQL statement errors and throw exceptions. If you want to troubleshoot SQL problems, you have to go to the log, which is a very painful thing. Especially, the log always outputs debugging information one by one or an SQL statement is abnormal but does not report an error in the log.

Wouldn’t it be nice if there was something that would automatically filter out the SQL statements in the log and bring me the parameters?

Like this query in the log:

SELECT 
    supply_materials.id, supply_materials.tax_code, 
    supply_materials.supplier_code, supply_materials.material_code,
    mdm_material.material_name, supply_materials.purchase_duration,
    supply_materials.material_type, supply_materials.is_valid, 
    supply_materials.operate_user, supply_materials.operate_time, 
    supply_materials.create_user, supply_materials.create_time FROM 
    mdm_material Right JOIN supply.supply_materials ON 
    mdm_material.material_code = supply_materials.material_code 
where 1=1 
    and supply_materials.supplier_code ~* ? 
    and supply_materials.material_type =? and supply_materials.is_valid='effective'

 ==>Parameters: GY (String), material (String)Copy the code

Finding this statement and having to match the argument to the question mark is really torture. The Mybatis Log Plugin has been installed in the Mybatis Log Plugin.The SQL statement just executed is automatically printed, along with the parameters. It’s working pretty well so to speak.

Here’s how to install and use this thing.

  1. Install Mybatis Log Plugin in marketPlace You can also Install Plugins From Disk and Install the jar package.

Here’s how to do it: Place the downloaded JAR files in a folder, preferably one dedicated to IDEA plug-ins, for later searching. Then, go to Settings ->plugins-> Nstall plugins From Disk in the top right pinion -> select this file ->apply->OK

  1. Restart IDEA may be prompted, which can be found in the following menu after restarting. If not, look in View — >Tool Windows.

End, scatter flowers!