是否有针对未关闭的 PreparedStatements/ResultSets/Connections 或任何使用标准 Java SQL 库的任何 IntelliJ 检查?
我必须使用一个相对较旧的 Java 代码库,它使用了很多未包装在框架中的 SQL,因此请记住 finally
block 中的所有特殊关闭逻辑,即使是非常小的一些 SQL 会变得令人厌烦且容易出错。
最佳答案
一定要开启以下检查: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.
请注意,您可以搜索检查列表以找到您需要的。
关于java - 未关闭的 PreparedStatements/ResultSets/Connections 的 IntelliJ 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32356004/