Re: Database Connection Question
Thank you for these tips The point is that I do use multiple EOF stacks. I clearly admit that each EOObjectStoreCoordinator gets its own set of db connections. It only needs a single connection to work. Let's say single connection for each used database ;) In fact that is a goal I'd like to achieve to have a single connection for a EOF stack per database. That is what should happen *if* the connection dictionaries are equals() and you close the jdbc2info connections. Hmm. I'll put some more research into it. Strangely I do have multiple connections yet. I should find what ruins equality... if it is so I use separate EOF stack to access previous year data stored in a separate database with identical structure. That is why I employ EODatabaseContext.forceConnectionWithModel(model,connectionDict,ec) And that is why my models get identical connection dictionary. I am not sure if that is the best / right way to do this. I did not find any other method to connect a model do different databases. You need to create a new model group for the new EOF stack (the one using data from previous years), add the models, and update the connection dictionaries before using the EOF stack. I'not sure I got it right. I'm using the same models to access different databases. Should I clone them and place copies to another model group? So the modelGroup is going to be the root of EOF stack, not the DatabaseContext this time? And by the way, what is this method intended for after all? ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
On Nov 30, 2010, at 2:59 AM, Gennady Kushnir wrote: Thank you for these tips The point is that I do use multiple EOF stacks. I clearly admit that each EOObjectStoreCoordinator gets its own set of db connections. It only needs a single connection to work. Let's say single connection for each used database ;) In fact that is a goal I'd like to achieve to have a single connection for a EOF stack per database. That is what should happen *if* the connection dictionaries are equals() and you close the jdbc2info connections. Hmm. I'll put some more research into it. Strangely I do have multiple connections yet. I should find what ruins equality... if it is so If you are using Wonder or the GVC frameworks (and likely every other major WO framework) there are classes to set all of this to the same dictionary as the models are loaded. I use separate EOF stack to access previous year data stored in a separate database with identical structure. That is why I employ EODatabaseContext.forceConnectionWithModel(model,connectionDict,ec) And that is why my models get identical connection dictionary. I am not sure if that is the best / right way to do this. I did not find any other method to connect a model do different databases. You need to create a new model group for the new EOF stack (the one using data from previous years), add the models, and update the connection dictionaries before using the EOF stack. I'not sure I got it right. I'm using the same models to access different databases. Should I clone them and place copies to another model group? That would be my first plan. So the modelGroup is going to be the root of EOF stack, not the DatabaseContext this time? It does not change the root, just changes what the context uses to talk to the database. And by the way, what is this method intended for after all? I am not sure. 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 smime.p7s Description: S/MIME cryptographic signature ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
The point is that I do use multiple EOF stacks. I clearly admit that each EOObjectStoreCoordinator gets its own set of db connections. It only needs a single connection to work. Let's say single connection for each used database ;) In fact that is a goal I'd like to achieve to have a single connection for a EOF stack per database. I use separate EOF stack to access previous year data stored in a separate database with identical structure. That is why I employ EODatabaseContext.forceConnectionWithModel(model,connectionDict,ec) And that is why my models get identical connection dictionary. I am not sure if that is the best / right way to do this. I did not find any other method to connect a model do different databases. I am quite interested if multiple models could share single db context and thus lower the number of open connections. They can't share db contexts across EOF stacks. That's quite clear. I am speaking about several models within one stack connecting to the same database. During my experimentations I have found that it is EODatabaseContext.forceConnectionWithModel(...) the one who create a connection for a mentioned model which does not get reused afterwards. May be that is aforementioned JDBCinfo connection? Maybe or it could be a side effect or misuse of that method. Are the models already connected in the new EOF stack before you call this? No, they are not connected. I call this in Application constructor. And also this method is the only place where models get correct connection dictionary. Gennady ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
On Nov 24, 2010, at 2:18 AM, Gennady Kushnir wrote: The point is that I do use multiple EOF stacks. I clearly admit that each EOObjectStoreCoordinator gets its own set of db connections. It only needs a single connection to work. Let's say single connection for each used database ;) In fact that is a goal I'd like to achieve to have a single connection for a EOF stack per database. That is what should happen *if* the connection dictionaries are equals() and you close the jdbc2info connections. I use separate EOF stack to access previous year data stored in a separate database with identical structure. That is why I employ EODatabaseContext.forceConnectionWithModel(model,connectionDict,ec) And that is why my models get identical connection dictionary. I am not sure if that is the best / right way to do this. I did not find any other method to connect a model do different databases. You need to create a new model group for the new EOF stack (the one using data from previous years), add the models, and update the connection dictionaries before using the EOF stack. I am quite interested if multiple models could share single db context and thus lower the number of open connections. They can't share db contexts across EOF stacks. That's quite clear. I am speaking about several models within one stack connecting to the same database. During my experimentations I have found that it is EODatabaseContext.forceConnectionWithModel(...) the one who create a connection for a mentioned model which does not get reused afterwards. May be that is aforementioned JDBCinfo connection? Maybe or it could be a side effect or misuse of that method. Are the models already connected in the new EOF stack before you call this? No, they are not connected. I call this in Application constructor. And also this method is the only place where models get correct connection dictionary. 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 smime.p7s Description: S/MIME cryptographic signature ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
Hello Chuck and others. I'd like ask some more questions ) 2010/8/27 Chuck Hill ch...@global-village.net: 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 (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
Hello Gennady, Hello Chuck and others. I'd like ask some more questions ) 2010/8/27 Chuck Hill ch...@global-village.net: 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? If you are using Wonder, you could use the following in your Properties file ## Class name to use instead of the JDBCAdaptor, the ERXJDBCAdaptor supports ## connection pooling er.extensions.ERXJDBCAdaptor.className=er.extensions.jdbc.ERXJDBCAdaptor 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? Can't respond on this one, but the property above should fix all this. Xavier 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 (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40anazys.com This email sent to webobje...@anazys.com ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
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 Hillch...@global-village.net: 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 (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/stefan.klein%40buero-sde.de This email sent to stefan.kl...@buero-sde.de ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
Hi Guys; One per db context and no. My problem is that I see my app opening more connections than a number of models it has. Mike talked through a work-around for this bug to me recently on here. I had the same problem eating lots of connections into an Oracle database from the app-servers. If you are using ERXJDBCAdaptor.java then it should resolve this problem I think; otherwise I created my own JDBCAdaptor and copied in the methods jdbcInfo() and typeInfo() verbatim. This seems to have resolved the problem. cheers. -- Andrew Lindesay www.silvereye.co.nz ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Database Connection Question
On Nov 23, 2010, at 3:01 PM, Gennady Kushnir wrote: Hello all Thanks for you replies. Looks like I have enough to explore yet. It should not be creating more unless you are creating more EOF stacks in you code. The point is that I do use multiple EOF stacks. I clearly admit that each EOObjectStoreCoordinator gets its own set of db connections. It only needs a single connection to work. I use separate EOF stack to access previous year data stored in a separate database with identical structure. That is why I employ EODatabaseContext.forceConnectionWithModel(model,connectionDict,ec) And that is why my models get identical connection dictionary. I am not sure if that is the best / right way to do this. Joe (Little), weren't you doing something similar? I am quite interested if multiple models could share single db context and thus lower the number of open connections. They can't share db contexts across EOF stacks. During my experimentations I have found that it is EODatabaseContext.forceConnectionWithModel(...) the one who create a connection for a mentioned model which does not get reused afterwards. May be that is aforementioned JDBCinfo connection? Maybe or it could be a side effect or misuse of that method. Are the models already connected in the new EOF stack before you call this? Chuck In my case I decided to close that AdaptorChannel myself after connecting model to database. As a result I have no dangling connections after launch. And when an app needs data for some real work it opens new connection that gets reused afterwards. If anyone interested you may review my code on github: https://github.com/baywind/reusables/blob/master/Sources/net/rujel/reusables/DataBaseConnector.java Here I am speaking about row 222 and around 2010/11/23 Chuck Hill ch...@global-village.net: Hi, On Nov 23, 2010, at 1:54 AM, Gennady Kushnir wrote: Hello Chuck and others. I'd like ask some more questions ) 2010/8/27 Chuck Hill ch...@global-village.net: 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 ? They all need to have the same connection dictionary. This allows one database schema to be partitioned between several models. I could be wrong too :-) All the models might be part of the same EODatabase, and each model gets its own EODatabaseConnection. I am too lazy to look it up right now. 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. IIRC, that method is not the normal method that EOF uses so the results may be different than normal. Also note that the models needs to have the exact same* (equals()) connection dictionaries. * OK, they don't need to be fully equals() but the main entries must be equals(). And would it make sense to somehow force all these models to single db context? That depends on the EOF implementation. 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. That is the jdbc2info connection. It is an old bug in EOF that this does not get closed or reused. The JDBC adaptor in Wonder will close this, but someone (Simon?) was reporting problems generating PKs with it under load recently. 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. It should not be creating more unless you are creating more EOF stacks in you code. 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? Mike said, this is very tricky. The code is in, or referenced by, the JDBC adaptor in Wonder. I think. Chuck 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.