Re: When and where to close the connection in a struts-web-application?
| Newsgroups | gmane.comp.java.ozone.user |
|---|---|
| Message-ID | <[email protected]> |
-----Ursprüngliche Nachricht----- Von: <[email protected]> Gesendet am: 09. Mrz 2004, 01:36:49 > Hi Per, > > I believe the error is happening on the client side. We're tracking > connections and closing as appropriate in order to avoid the problem. > > Would it be better for ExternalDatabase to refuse the connection or reuse > an old existing one? In fact, it already does! ozone "connections" are not comparable to jdbc connections. ozone finds out for itself what client side threads access the db in what transaction (and does socket connection pooling and multiplexing). You just need one ExternalDatabase object for the entire application/session. For a web app just store the db object in the http session or something and then just use it from all threads. In short: no need to open/close "connections". Just for the FAQ and to illustrate things a bit more: The notion of a "connection" is not needed by ozone. ozone uses (client side) threads and bounds transactions to them; in fact, the programmer does this by calling an ozone method or accessing an ozone object or explicitly begin/end a transaction. The view to the content of the db depends on the thread you are currently in and the transaction (or no transaction) that is currently bound to that thread. this is completely different concept than jdbc connections. ozone offers a lot more elegant posibilities here. // thread1, no tx ozoneObject.getNumber(); // returns say 1 ExternalTransaction tx = db.newTransaction(); tx.begin(); ozoneObject.setNumber( 2 ); ozoneObject.getNumber(); // now returns 2 tx.abort(); ozoneObject.getNumber(); // returns 1 again this even works with joining/leaving transactions by threads. A thread can join/leave different transactions and sees completely different db content. All this works transparent to the programmer, no "connections" are needed. Falko -- ______________________________________________________________________ Falko Braeutigam mailto:[email protected] SMB GmbH http://www.smb-tec.com ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click