Hi,
the logic is follows:
Every
Servlet will create a database object, which will query the database and return the result either boolean,
String or Vector back to those Servlets. The creation of the db object for every Servlet is summarize below:
public class ServletNAME extends HttpServlet
{
...
private sqlcmd cmd; ...
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, java.io.IOException
{ ...
if (cmd==null){ cmd = new sqlcmd(); } .....
For this coding, every servlet will share the same DB object for querying, In the past, I will not check "if (cmd==null)" and just let it create an object per request. But it seems waste resource.
But if every servlet share the same object, will it take risk when many people accessing the Servlets? Since I've no experience to build a multi-user application, so I am afraid of causing error for this arrangement. Pls recommend.