I've been programming for just a few years, and we have a default dll used for data access. It seems like there has been some data-mining or site scraping going on here lately, and although there are no issues with our SQL database connections, many of the programs that access the as/400 are keeping connections open and idle for long periods of time. I looked through our default data access dll and added code to close the connection after each function, but that didn't help. I have little experience with db2 / as/400 ... how do I close all of these open / idle connections from the code?
Asked
Active
Viewed 537 times
0
-
You should always use `using` when working with database connections. This will ensure proper closure of connections and the disposing of objects. See https://stackoverflow.com/questions/5243398/will-a-using-block-close-a-database-connection – VDWWD Oct 17 '17 at 14:38
-
We are using using 'using' but I read that could actually be part of the issue when dealing with as/400 - is that possible? – deebs Oct 17 '17 at 14:41
1 Answers
1
If you're using connections pools, that's working as designed.
Are you sure the connection is actually open? How are you determining that?
If you're just seeing locks held by the QZDASOINIT job on the IBM i, then that's also by design. The system will hard close tables (cursors) after the first use. When used again by the same job, the system will only pseudo-close them; in order to provide faster response when they are re-used.
If an operation needing exclusive access is attempted, the system will hard close the pseudo closed cursor.

Charles
- 21,637
- 1
- 20
- 44
-
I believe we are using connection pools. I'd like to turn that off as a test - what implications would that have? – deebs Oct 17 '17 at 17:59
-
1@deebs, just a performance degradation...as new connections will be repeatedly opened/closed. – Charles Oct 17 '17 at 18:48