EOF problems
EOF problems
- Subject: EOF problems
- From: "Richard Bruch(dland)" <email@hidden>
- Date: Fri, 05 Nov 2004 19:58:40 +0100
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