Hi Steve, Djam, Flemming, Ian, et al, On Wed, 24 Oct 2001 17:51:28 -0500 "Stephen J. Sanders" <ssanders@ku.edu> wrote concerning "access to db question": > Hi, > > I am trying to access the db from a compiled program. Why do you need a compiled program? Can't bratmain do what you need? Hoenstly, you'll find that using bratmain your life becomes much easier, since you really don't need to care too much about what's going on in BRAT. Also, it'd make it much easier for others to use your excellent work. > I first tried to figure out how to do this by following the > instructions in the "Don't Panic" manual. That's really not it's title. The title is The Hitchhikers Guide to BRAT with the cover illustration, saying in large friendly letters DON'T PANIC If you want to use a nickname, why not "The Guide"? [If you don't think this is funny, you haven't read Douglas Adams have you?] > Unfortunately, this has me using the BrParameterElementManager, > which isn't found. Arhm, "The Guide" is slightly out of date in this respect. I'll correct it soon. The correct name is BrCalibrationManager. BTW, you don't need to get a pointer to that manager in your script (or setup part). > So...I spent some time on this list and found the series of messages > indicating that one is not to use BrParameterElementManager. > However, I have not been able to find the correct message (must be > there, but without a search engine on the archive its not easy to > find stuff) saying how access is now supposed to be done. We want a search engine on those list ASAP! And why the heck can't RCF just do it? > Can someone point me to a script that correctly sets up the db > access stuff? > Thanks, > ...steve > On Wed, 24 Oct 2001 19:59:48 -0500 "Stephen J. Sanders" <ssanders@ku.edu> wrote concerning "Re: access to db question": > Hi again, > I'm still not managing to get access to the db. Trying to type in > the relevant > commands directly, I get: > > brat [0] BrCalibrationManager * calibManager = > BrCalibrationManager::Instance(); > brat [1] fBbCalibration = (BrBbCalibration *) > (calibManager->Register("BrBbCalibration",BrDetectorList::GetDetectorName(kBrBB))); > > GetDetectorParams Request > BrBbCalibration : BB > Warning in <BrRdbmDb::IsConnected>: No conenction to database BrahmsMain > on 67520st > > *** Break *** segmentation violation > > I have the magic talisman: > -rw------- 1 sanders users 367 Oct 10 16:34 .bratdbrc > located in my home directory. LOL > Do I need additional permissions (ie, does Betty need to configure > something) for this to work? Or, am I doing something else wrong? > Thanks for any suggestions... No, you don't need Betty to do anything. The port for MySQL has been opened in the BNL firewalls ("Demon what is thee name?" "none but legion, for we are many"). On Wed, 24 Oct 2001 21:15:41 -0400 "Flemming Videbaek" <videbaek@sgs1.hirg.bnl.gov> wrote concerning "Re: access to db question": > Steve, > > for reading you should only need to have the > BrahmsMain at rcas0005.rcf.bnl.gov with query and its password > BrahmsCalib ... > the on 65720.. looks strange. Have you set the > BrMainDb *mainDb= new BrMainDb::Instance() > mainDb->SetUserName("querey") > mainDb->SetHostName("rcas...") > mainDb->SetDbName("BrahmsMain"); Man Flemming, you should know this is not enough. > or equivalent in the script ? It is possible there is a firewall > problem! I am not sure how the rcas has been setup - Betty is on > vacation but if your problem persists I can contact RCF network > people. Unless the RCF people explicitly closses the MySQL port for the .ku.edu domain, there should be no problem. > Could you try your script from rcasxxx or the pii's Steve, do you see? Most people are using bratmain with scripts. On Thu, 25 Oct 2001 03:32:48 +0200 (CEST) Djamel Ouerdane <ouerdane@nbi.dk> wrote concerning "Re: access to db question": > Steve, > > You need some more stuff than what Flemming told: > in bratroot session you would do that: > > BrMainDb *mainDb= new BrMainDb::Instance() > mainDb->SetUserName("query") > mainDb->SetHostName("rcas0005.rcf.bnl.gov") > mainDb->SetDbName("BrahmsMain"); > > mainDb->Connect(); // very important!! > mainDb->ConnectToCalib(); > mainDb->ConnectToRun(); Well done Djam, BTW, similar lines are inserted into a configuration script when you do "M-x brat-config-skell" in Emacs! > note that these methods return a boolean to check if you really > connected to these databases. > > then: > > > BrCalibrationManager* calMan = BrCalibrationManager::Instance();w > > then > > BrBbCalibration* bbl = (BrBbCalibration*)calMan-> > Register("BrBbCalibration", "BBL"); > > same for BBR > > the database makes a difference between BBL and BBR. So don't try to get > something with BB. Hmm. These kind of things we need to document somewhere I guess. > This will work, I made it many times in a bratroot session this way > to debug. > > In order to visualize a revision, it's more complicated in a bratroot > session. For checking a BB calibration with a not so bad display, > use an application I wrote in brahms_app/do_app/db (BbDbBrowser) > > its usage is trivial: > > BbDbBrowser -r <run> -c <some calibration> -D <detector name> > > -c takes: pedestal, deltatdc, adcgain, tdcgain, slewing or all > -D takes: BBL, BBR (upper or lower case). The default is both. Well, you can do it in bratroot: BrMainDb *mainDb= new BrMainDb::Instance() mainDb->SetUserName("query") mainDb->SetHostName("rcas0005.rcf.bnl.gov") mainDb->SetDbName("BrahmsMain"); mainDb->Connect(); mainDb->ConnectToCalib(); mainDb->ConnectToRun(); BrBbCalibration* bbl = (BrBbCalibration*) BrCalibrationManager::Instance()-> Register("BrBbCalibration", "BBL"); BrCalibrationManager::Instance()->Init(); BrRunInfoManager::Instance()->Update(myRunNumber); BrRunInfo* runInfo = BrRunInfoManager::Instance()->GetCurrentRun(); BrCalibrationManager::Instance()->Update(runInfo->GetUnixStartTime(), runInfo->GetUnixEndTime()); bbl->Print(); Not so complicated after all, is it? On Wed, 24 Oct 2001 22:12:51 -0500 "Stephen J. Sanders" <ssanders@ku.edu> wrote concerning "Re: access to db question": > Dear Djamel and Flemming, > Thanks for the additional info...I was missing the maing Db stuff. > However.... (running on rcas, I get the same response running at home > with the brat current as of this afternoon): > > ******************************************** > * * > * W E L C O M E to B R A T * > * Version 2.00/38 * > * * > * All Classes preloaded * > * Library, Header and Script paths set * > * * > ******************************************** > > brat [0] BrMainDb *mainDb = new BrMainDb::Instance() > Error: Symbol BrMainDb::Instance is not defined in current scope > FILE:/tmp/fileudpOe8_cint LINE:1 > Error: type BrMainDb::Instance not defined FILE:/tmp/fileudpOe8_cint LINE:1 > *** Interpreter error recovered *** > brat [1] > > > Do I need to do something special before creating the BrMainDb instance? You can not "create" a BrMainDb instance! BrMainDb is a singleton (it actually says so in the HTML documentation). There for, you should never use the "new" operator with BrMainDb (In fact, you could get severly burned due to the polymorphic nature of the BrDb classes). On Thu, 25 Oct 2001 05:32:07 +0200 (CEST) Djamel Ouerdane <ouerdane@nbi.dk> wrote concerning "solution": > > > > brat [0] BrMainDb *mainDb = new BrMainDb::Instance() > > Error: Symbol BrMainDb::Instance is not defined in current scope > > Haha Steve, you're doing easy mistakes but really hard to find :) > > I think if you remove the "new" in your statement, that should be ok > ;-D The point is, that like the manager classes, we can only have one BrMainDb, and since we need to be able to get it from any point in the code, the static(!) method BrMainDb:Instance() will create the object if not done before! That is the only way one can create a BrMainDb object. On Thu, 25 Oct 2001 09:08:00 +0200 "Ian Bearden" <bearden@nbi.dk> wrote concerning "RE: access to db question": > Steve, Flemming, > I don't think there is a problem with a firewall, as we can access > the db from .nbi.dk. You should have a proper .bratdbrc file in > your home directory. If you do not, you will experience problems > when trying to connect to the db. Well, no, that's not correct. What will happen is that you'll be prompted with for the password of the currently selected user (if you didn't set the user name, you'll be prompted for that first, obviously). Hence, ~/.bratdbrc (or the magic talisman as Steve calls it :-) is a way of bypassing the prompt (which is what you need in a batch environment). All in all, many misunderstandings was shown in the above mails. Apart from the name change of BrParameterElementManager to BrCalibrationManager not having been propegated to "The Guide", all of the above is in fact documented in "The Guide" and the HTML class documentation. Please read that (Yep, that's a RTBM). If you miss something, or have some additional info that you think should go into the guide, please, do add it. Yours, Christian Holm Christensen ------------------------------------------- Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 DK-2200 Copenhagen N Cell: (+45) 28 82 16 23 Denmark Office: (+45) 353 25 305 Email: cholm@nbi.dk Web: www.nbi.dk/~cholm
This archive was generated by hypermail 2b30 : Thu Oct 25 2001 - 06:04:58 EDT