- From: Brax <JBrax@csi.com>
- Date: Fri, 3 Mar 2000 12:01:57 -0500 (EST)
- To: <walter@softplan.com.br>
- Cc: <www-jigsaw@w3.org>
- Message-ID: <002501bf8531$703cfcc0$52838282@treso1082>
I've sended last month an example of servlet for accessing database; so here it is again. Problems I've go is : - I'm not concerned about number of users ( history - but it's another story developped later ) but I'm rather concerned about concurrent access. The idea developped in the source is to have a pool of database connection. This servlet is called by other servlet retrieving parameters and passing it : RequestDispatcher dispatch = getServletContext().getRequestDispatcher( SqlServlet + "?File=" + Mess1 + Mess2 + Mess4 ); dispatch.include(req, res); - So, servlet connecting to database process its pool of connection, execute statements ( sql orders are stored in files, with keywords for parameters ), and returns results. - Meanwhile, if a user cancel it's query, servlet goes on ..., until finished. I do not process here DELETE messages. So, if the same TCP adress comes again, it gets the same database connection and waits until the first query finish ( bad, bad, bad ...). - Source code is Serv3do3.java Otherwise, for counting number of access, I use the MaintainedServlet ( from bibli ), that I picked somewhere. It works with ServletMaintenance, and for storing value, I use TextCounter and TextCounterDatabase. All of those were developped by Matt Tucker, at CoolServlets.com - I modified for my own needs - have a look there, they might have some more good ideas. My servlet using those is called CSTextCounter, once more called by another servlet, and once more modified for internationalization. Have fun - j Brax
Attachments
- application/octet-stream attachment: Serv3do3.java
- application/octet-stream attachment: TextCounterDatabase.java
- application/octet-stream attachment: ServletMaintenance.java
- application/octet-stream attachment: TextCounter.java
- application/octet-stream attachment: MaintainedServlet.java
- application/octet-stream attachment: CSTextCounter.java
Received on Friday, 3 March 2000 12:05:53 UTC