DB Connection Not Closed (ARCH8084)
هذا المحتوى غير متوفر بلغتك بعد.
Key kotlin.performance.db-connection-not-closed · Severity error · Category performance
Flags DriverManager.getConnection / dataSource.connection / prepareStatement whose result is not wrapped in use { } or closed in finally.
Incorrect
Section titled “Incorrect”val c = dataSource.connectionc.prepareStatement(sql).execute()Correct
Section titled “Correct”dataSource.connection.use { c -> c.prepareStatement(sql).use { it.execute() } }Wrap connections and statements in use { } so they return to the pool on every path.