closing database connections after StoredProcedure calls and Migrations.

This commit is contained in:
simonredfern 2026-01-22 18:41:01 +01:00
parent 6ad3689fd3
commit 7efbf6389a
2 changed files with 14 additions and 8 deletions

View File

@ -648,8 +648,11 @@ object Migration extends MdcLoggable {
if (performWrite) {
logFunc(ct)
val st = conn.createStatement
st.execute(ct)
st.close
try {
st.execute(ct)
} finally {
st.close()
}
}
ct
}

View File

@ -58,12 +58,15 @@ object StoredProcedureUtils extends MdcLoggable{
val sql = s"{ CALL $procedureName(?, ?) }"
val callableStatement = conn.prepareCall(sql)
callableStatement.setString(1, procedureParam)
callableStatement.registerOutParameter(2, java.sql.Types.LONGVARCHAR)
// callableStatement.setString(2, "") // MS sql server must comment this line, other DB need check.
callableStatement.executeUpdate()
callableStatement.getString(2)
try {
callableStatement.setString(1, procedureParam)
callableStatement.registerOutParameter(2, java.sql.Types.LONGVARCHAR)
// callableStatement.setString(2, "") // MS sql server must comment this line, other DB need check.
callableStatement.executeUpdate()
callableStatement.getString(2)
} finally {
callableStatement.close()
}
}
logger.debug(s"${StoredProcedureConnector_vDec2019.toString} inBoundJson: $procedureName = $responseJson" )
Connector.extractAdapterResponse[T](responseJson, Empty)