Re: Database Connection Question
Re: Database Connection Question
- Subject: Re: Database Connection Question
- From: Stefan Klein <email@hidden>
- Date: Tue, 23 Nov 2010 11:22:50 +0100
Hi,
you can use the following to check who is creating your channels:
public Application()
{
super();
...
// register for database channel needed notification
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("createAdditionalDatabaseChannel", new Class[] {
NSNotification.class }),
EODatabaseContext.DatabaseChannelNeededNotification, null);
...
}
public void createAdditionalDatabaseChannel(NSNotification notification)
{
EODatabaseContext dbContext = (EODatabaseContext)
notification.object();
if (dbContext != null)
{
EODatabaseChannel dbChannel = new EODatabaseChannel(dbContext);
// consensus is that if you need more than 30 open channels,
// you might want to re-think something in your code or model
NSLog.err.appendln("createAdditionalDatabaseChannel");
if (dbContext.registeredChannels().count() < 30)
{
EOAdaptorContext adaptorContext = dbContext.adaptorContext();
dbContext.registerChannel(dbChannel);
}
}
}
Stefan
Am 23.11.10 10:54, schrieb Gennady Kushnir:
Hello Chuck and others.
I'd like ask some more questions )
2010/8/27 Chuck Hill<email@hidden>:
On Aug 25, 2010, at 11:10 PM, Dov Rosenberg wrote:
I am revisiting some old EOF documentation and wanted to make sure I understood a few things. Are the following statements true?
* When an EOModel is found and connected to a database when the app starts up each database connection is mapped to an EODatabaseChannel?
I think that EODatabaseContext is more correct than EODatabaseChannel. The context will then use the channel. A db context can handle multiple models (the connection information needs to be the same).
How can single db context handle multiple models ? I see that
EODatabaseContext.forceConnectionWithModel(model,cd,ec)
returns different objects for different models, whereas most of my
models point to the same database with the same connection dictionary.
And would it make sense to somehow force all these models to single db context?
Is there a default number of EODatabaseChannels opened when the app starts up? Is there a configuration setting that I can set to add more?
One per db context and no.
My problem is that I see my app opening more connections than a number
of models it has.
And those connections do not close even after more than an hour not
used. And it does not reuse all of them for later requests but may
create even more connections.
As a result when running multiple instances on a server with limited
DB-connections I do get "too many connections" error sometimes.
How could I fight it? Is it possible to control the number of open
connections and close unused ones after certain idle time?
Gennady Kushnir
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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