Thanks, Jeanne. We still don't know exactly what the issue is, but I've been trying to help find a solution.
Now that you mention it, though, I have absolutely no idea how the DataSource is being initialized. The methods used to get the connection are static methods so calling those would not require the constructor to be invoked. Unfortunately, I'm only vaguely related to this project so I don't know all the inner workings. Obviously, the DataSource
is being intialized somewhere along the way, though, because the database connection is working. Odd, but I'll look into it. I'm sure there's an explanation.
However, in order to try to fix the problem of a prematurely closed connection, I've suggested that they modify the code to look something more like this (kind of a modified version of a singleton
pattern):
I'm hoping that, by modifying the code in such a way, a check will be done every time a connection is to be used to ensure that the connection is open. Looking through the existing code, it looks like a single connection was being opened and then being used for a number (sometimes a rather large number) of operations. The reason I modified the connection member to be private was just to force the sublcasses that would use it to go through the getConnection() method.
As I told the folks working on this project - I don't know that it'll really fix the problem. It'll add a small amount of overhead, but it shouldn't really hurt anything.
Does that make sense? Any thoughts on this approach?