• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: connectWithModelNamed - Wierd Goings On
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: connectWithModelNamed - Wierd Goings On


  • Subject: Re: connectWithModelNamed - Wierd Goings On
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Sat, 17 Jan 2004 00:13:24 +0000

From: Chuck Hill <email@hidden>
Reply-To: email@hidden
To: Jonathan Fleming <email@hidden>
CC: email@hidden
Subject: Re: connectWithModelNamed - Wierd Goings On
Date: Fri, 16 Jan 2004 15:00:06 -0800

how does this get called?

This little lot in the Application constructor:

String db_MODEL_NAME = "BTT";
String db_DRIVER = "";
String db_URL = "jdbc:microsoft:sqlserver://192.168.0.4\\\\DEVBOXSQLSERVER:1433;DatabaseName=JandM;SelectMethod=cursor;Trusted_Connection=yes";
String db_USERNAME = "whatever";
String db_PASSWORD = "whatever";
setDBConnectionForModel( db_MODEL_NAME, db_DRIVER, db_URL, db_USERNAME, db_PASSWORD);


/*------------------*/

String ts_MODEL_NAME = "BTT";
String ts_DRIVER = "";
String ts_URL = "jdbc:microsoft:sqlserver://000.00.000.00:1433;DatabaseName=BTT;SelectMethod=cursor;Trusted_Connection=yes";
String ts_USERNAME = "whatever";
String ts_PASSWORD = "whatever";
setDBConnectionForModel( ts_MODEL_NAME, ts_DRIVER, ts_URL, ts_USERNAME, ts_PASSWORD);


/*------------------*/

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>



_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband
_______________________________________________
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.

  • Prev by Date: Open source Hill's book
  • Next by Date: Re: Open source Hill's book
  • Previous by thread: Re: connectWithModelNamed - Wierd Goings On
  • Next by thread: Re: Hill's book
  • Index(es):
    • Date
    • Thread