Hi,


I have a question regarding usage of db connection in WebKit and (related to it), how thread-safe servlets are.

Currently I have a db conn. as a module global variable in a sitepage and it is used by several servlets. But I'm not sure this is a good way to deal with db. Anyway it is probably buggy as most DB-API interfaces are not thread-safe and WebKit is multithreaded and hence there is a possiblilty for crash due to simulationous access to the same conn from multiple threads.

I think db conn should be created when needed and released when unneeded, as to conserve system resources. But was is the best way to achieve this in WebKit?

I think about using a conn pool and storing a conn in a session variable or in a servlet instance variable (via awake/sleep). Only not sure whether it would be guaranteed that it can't be accessed from mulitiple threads.

If session variable or servlet instance variable can be accessed from mulitiple threads then I see no other route as to request conn only where it needed (in a method body) and release it immediately.

What do you think?



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to