My VideoServlet application uses a JDBC Connection object. It is very naughty of me to use this Connection as a global variable.
One solution: Should I change the argument lists of all methods that use a connection object. For example, in the AddActionHandler there is a method called doSecureAction(ServletData servletData). Should I overload this method to take a Connection object?
Or is there a more elegant solution that I should consider?
Any hints would be greatly appreciated.
Marilyn de Queiroz
Joined: Jul 22, 2000
It is very naughty of me to use this Connection as a global variable.
A global Connection is a bad idea. Some day you're gonna have to think along the lines of thousands of users at once.
Should I change the argument lists of all methods that use a connection object.
Would you still be using the same connection for each of those methods? Would it be better to get a new connection each time you need it and release it while you're doing other things that don't require a connection so someone else can use it?
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Mar 15, 2001
I had the same nit pick when I did this assignment, not more than a few weeks ago. It eluded me until the last, and Marilyn had to practically rub my nose in the solution before I saw it. The answer is one of those things that is so simple, and it becomes incredibly obvious after you've tripped over it! I will search for one of my posts!