eclair
eclair copied to clipboard
All DB Statement and ResultSet should be closed when no longer needed
I went through the code and to my surpise you don't close any Statement or ResultSet after use.
Afaik this is bad practice and can lead to degraded DB performance and resource leakes (if combined with bad JDBCD driver)
Simple example from: CompareDb.scala
A close() statement after the while(rs.next()) loop would immediately free up the resources
val rs1 = conn1.prepareStatement(s"SELECT * FROM $table1").executeQuery()
val rs2 = conn2.prepareStatement(s"SELECT * FROM $table2").executeQuery()
var hashes1 = List.empty[ByteVector]
while (rs1.next()) {
hashes1 = hash1(rs1) +: hashes1
}
rs1.close()
var hashes2 = List.empty[ByteVector]
while (rs2.next()) {
hashes2 = hash2(rs2) +: hashes2
}
rs2.close()