Re: connectWithModelNamed - Wierd Goings On
Re: connectWithModelNamed - Wierd Goings On
- Subject: Re: connectWithModelNamed - Wierd Goings On
- From: Chuck Hill <email@hidden>
- Date: Fri, 16 Jan 2004 15:00:06 -0800
- Organization: Global Village Consulting, Inc.
how does this get called?
Jonathan Fleming wrote:
I'm trying to do a programmatic connection to the DB and for the most
part the code below works but it does not load up all me eo's when i do
a search. It even throws and exception when I try to login to the
administration area saying that one of my DB colums is invalid. It is
not, however, because if I disable this connection dictionary everything
goes back to normal and I am able to access my admin area and all my
eo's load on a fetch.What have I done wrong with this code or what is
the best way to do a programmatic connection to you connection dictionary.
Icheck this with the value populated in the EOModel connection
dictionary and without them populated where I instead put the values in
the local variables of the Application.java constructor:
Here's the code:
/*------------------*/
public void setDBConnectionForModel(
String modelName,
String jdbcDriver,
String jdbcUrl,
String db_user,
String db_pass) {
if (modelName == null) { return; }
java.util.Enumeration e =
EOModelGroup.defaultGroup().models().objectEnumerator();
while (e.hasMoreElements() == true) {
EOModel m = (EOModel) e.nextElement();
// this part is used to isolate the model you wish to connect
if (m.name().equals(modelName)) {
EOModel model =
EOModelGroup.defaultGroup().modelNamed(modelName);
NSLog.out.appendln("===\r connection dictionary keys:
" + model.connectionDictionary().allKeys());
NSMutableDictionary overrides = new NSMutableDictionary();
overrides.takeValueForKey(jdbcDriver, "driver");
overrides.takeValueForKey(jdbcUrl, "URL");
overrides.takeValueForKey(db_user, "username");
overrides.takeValueForKey(db_pass, "password");
EODatabaseContext.forceConnectionWithModel(model,
overrides, new EOEditingContext());
NSLog.out.appendln(" the EODatabaseContext is: " +
EODatabaseContext.forceConnectionWithModel(model, overrides, new
EOEditingContext()));
NSLog.out.appendln( " the connection dictionary
content is: \r" + overrides );
// other stuff can be done here as seen fit: setting
isolation level,
// password, etcetera...
m.setConnectionDictionary(overrides);
}
}
}
/*------------------*/
Many thanks
Jonathan :^)
_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you.
http://www.msn.co.uk/internetaccess
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
It is a funny thing about life; if you refuse to accept
anything but the best, you very often get it."
-- W. Somerset Maugham
<shamelessPlug>
Practical WebObjects
http://www.amazon.com/exec/obidos/tg/detail/-/1590592964
</shamelessPlug>
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.