Yes, your sample is threadsafe.
It is also a good idea to open the db in init() method and to open a new tx for each incoming request.
[EMAIL PROTECTED] wrote:
Hello,
I'd like to use OJB/ODMG in a tomcat environement without using the
ojb-C/S-architecture.
Is the following servlet threadsafe? (I mean the doGet()-method, not the
init()-method).
#################################################
public class gaga extends HttpServlet {
static Implementation odmg ; static Database db ; public void init(ServletConfig config) throws ServletException {
super.init(config);
if (odmg==null){ this.odmg = OJB.getInstance(); this.db = odmg.newDatabase(); }
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, java.io.IOException {
Transaction tx = odmg.newTransaction();
tx.begin();
/* do the interesting things*/
tx.commit();
}
}
################################################
If yes, is it a good solution?
If no, is there a threadsafe version for my servlet?
Thanks a lot for any help
Thomas
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>