Re: EOF problems
Re: EOF problems
- Subject: Re: EOF problems
- From: "Richard Bruch(dland)" <email@hidden>
- Date: Sun, 07 Nov 2004 19:36:54 +0100
Damien,
i don't think that disconnecting in sleep() is a good idea. Oracle
connects are quite expensive in terms of time. Your app would experience
performance problems if you create a connection on every request to it.
This is not a WO issue but rather an Oracle issue.
In our case it is OK if a connection persists for the session lifetime.
If you expect many sessions to be active at the same time it might be
better to keep the list of open connections(i mean the corresponding
EODatabaseContext objects) in a dictionary keyed by the user name so
that you can reuse them. There are usually not many database users in a
particular database instance and by starting several instances of your
applicaton with concurrent request handling = NO you could achieve quite
good response times without wasting database resources.
Regards
Richard
Damien Lust wrote:
Thanks Richards,
But do you know when it's the best moment to call the static method
disconnect(EODatabaseContext dctx)
in session.sleep()?
An to recreate one?
On 05 Nov 2004, at 19:58, Richard Bruch(dland) wrote:
Hello Damien,
we also needed to write an app with a unique database connection per
session since a session were opened on behalf of a distinct database
user like sys, system or scott.
To do that we used documented means of attaching an EOEditingContext
to a separate EOObjectStoreCoordinator and forcing connection with a
given connection dictionary. In such a case a database context and an
adaptor channel get created so that a new database connection gets
established. Our login action looked like that:
WOComponent tryLogin(String name, String pwd, String serverId)
{
EOEditingContext ectx = null;
try
{
EOModel model = <get desired model>;
NSMutableDictionary override = new NSMutableDictionary();
override.setObjectForKey(name, "userName");
override.setObjectForKey(pwd, "password");
override.setObjectForKey(serverId, "serverId");
ectx = new EOEditingContext(new EOObjectStoreCoordinator());
EODatabaseContext dctx =
EODatabaseContext.forceConnectionWithModel(model, override, ectx);
}
catch(Exception e)
{
....
}
Session session = (Session)session();
session.setDefaultEditingContext(ectx);
return pageWithName(<your page name>);
}
Also there is a note in the EO documentation that states that a
connection gets closed by EO as soon as the last adaptor channel
attached to it gets closed. We tried following sequence and it worked:
static void disconnect(EODatabaseContext dctx)
{
try
{
NSArray channels = dctx.registeredChannels();
for(int i = 0; i < channels.count(); i ++)
{
EODatabaseChannel dc =
(EODatabaseChannel)channels.objectAtIndex(i);
if(dc.adaptorChannel().isOpen())
dc.adaptorChannel().closeChannel();
}
}
catch(Exception e)
{
...
}
}
i can't garantee that this would work faultlessly with every database
adaptor but with Oracle we had no problems.
Regards
Richard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >EOF problems (From: "Richard Bruch(dland)" <email@hidden>) |