简体   繁体   中英

IntelliJ inspections for unclosed PreparedStatements/ResultSets/Connections

Are there any IntelliJ inspections for unclosed PreparedStatements/ResultSets/Connections or anything using the standard Java SQL libraries?

I have to work with a relatively old Java codebase that uses a lot of SQL that isn't wrapped in a framework, so remembering all the special closing logic in the finally blocks for even very small bits of SQL can become tiresome and error-prone.

Be sure to turn on the following inspection: Settings > Editor > Inspections > Java > Resource management issues > "JDBC resource opened but not safely closed"

Reports any JDBC resource which is not safely closed in a finally block. Such resources may be inadvertently leaked if an exception is thrown before the resource is closed. JDBC resources reported by this inspection include java.sql.Connection, java.sql.Statement, java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.ResultSet.

Please note that you can search the inspections list to find ones you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM