SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    pt
    pt is offline
    Member
    Join Date
    Feb 2001
    Location
    US
    Posts
    43
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    *error * ... already connected

    hi all,

    i am using the script mentioned below to connect to a database (postgres) on linux. when i run the script it says that the connection is already made, I have a DB_disconnect statement at the end of the script & am also using DB_Disconnectall for breaking the connection.

    for the connection i have the drivers installed & have also specified the dsn for the database

    can someone tell me why is there a problem & how can i break the connection, why is HDBC not being taken as a variable, I have already defined it as one.

    I sometimes also get the error -- HDBC is not defined as a variable

    --------------------------
    [ ] HDATABASE hdbc
    [ ] HSQL hstmnt
    [ ] INTEGER id, recordid
    [ ] STRING sDeptName, driver, sExpectedValue, sTestValue
    [ ] BOOLEAN status
    [ ]
    [ ] //disconnect all the connections
    [ ] DisconnectAll ()
    [ ]
    [ ]
    [ ]
    [-] // connect to Postgresql
    [ ] hdbc = DB_Connect ("dsn=post")
    [-]
    [ ] TestVerification ( sExpectedValue, sTestValue)
    [ ] if ( sExpectedValue == sTestValue )
    [ ] Print ("Test was successful")
    [ ] else
    [ ] raise 1, "ERROR: Test verification failed"
    [ ] return
    [ ] ErrorHandler ()
    [ ] Print (ExceptData())
    [ ] // This script prints:
    [ ] // ERROR: Test verification failed
    [ ] return
    [ ] // retrieve info from Department table
    [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM aduser")
    [-] // process the information that came back
    [-] print ("Here’s the info in the Department table:")
    [ ] print ()
    [ ] while (DB_FetchNext (hstmnt, recordid))
    [ ] print ("Dept: {recordid} ")
    [ ] // release resources (unneeded really
    [ ] // because immediately followed by disconnect)
    [ ] DB_FinishSQL (hstmnt)
    [ ] // disconnect
    [ ] DB_Disconnect (hdbc)
    [ ]
    [ ] //disconnect all the connections
    [ ] disconnectall ()
    [ ]
    P.T.

  2. #2
    Super Member
    Join Date
    Jul 1999
    Location
    Rancho Santa Margarita, CA
    Posts
    1,439
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: *error * ... already connected

    Looks like the errors you were getting are valid ones.
    You did a DisconnectAll () which by definition will "Disconnects all currently connected machines." not necessarily the same as DB_Disconnect () which will "Disconnects SilkTest from the database system and releases all resources.".
    So when you followed DisconnectAll () with a DB_Connect (), it could be true that "you are already connected to that Database".
    Check the Online Help for the differences between the following:
    Connect () vs DB_Connect ()
    Disconnect () vs DB_Disconnect ()

    From your example, it is kind of hard to tell where your testcase begins and ends. You have the HDATABASE hdbc...DB_Connect () stuffs together with your other functions TestVerification () and ErrorHandler ().



    [This message has been edited by Gilbert (edited 03-21-2001).]

  3. #3
    rg
    rg is offline
    Member
    Join Date
    Feb 2000
    Posts
    98
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: *error * ... already connected

    DisconnectAll() is for managing connections with agents. You should use DB_Disconnect() instead of using DisconnectAll() in this case.

  4. #4
    pt
    pt is offline
    Member
    Join Date
    Feb 2001
    Location
    US
    Posts
    43
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: *error * ... already connected

    HI,

    I HAVE REMOVED THE DISCONNECTALL STATEMENT FROM THE SCRIPT & STILL I AM GETTING THE connect error.

    is there a problem with the HDBC not being taken as a variable by the script.I don't know but i am getting that error too as "variable not defined.

    please advice

    PT
    P.T.

  5. #5
    Super Member
    Join Date
    Jul 1999
    Location
    Rancho Santa Margarita, CA
    Posts
    1,439
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: *error * ... already connected

    PT,

    Maybe you can re-paste a copy of your testcase. As I mentioned earlier, the sample you have does not show where your testcase begins and ends.
    I have not worked with Linux but, with Unix and NT Servers, I have no problems connecting to the Databases (Local or Remote).

    Show a sample of your testcase like:

    testcase Testing_Linux_Connection ()
    [ ] HDATABASE hdbc
    [ ] HSQL hstmnt
    [ ]
    [ ] // connect to Solumina Database
    [ ] hdbc = DB_Connect (sConnectString)
    [ ]
    [ ] // retrieve info from table
    [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT sample FROM Sample_table")
    [ ]
    [ ] // process the information that came back
    [+] while (DB_FetchNext (hstmnt, sSample))
    [ ] // release resources (unneeded really
    [ ] // because immediately followed by disconnect)
    [ ] DB_FinishSQL (hstmnt)
    [ ]
    [ ] // disconnect
    [ ] DB_Disconnect (hdbc)
    [ ]

    -----
    Maybe you have your DB stuffs outside your testcase???


  6. #6
    pt
    pt is offline
    Member
    Join Date
    Feb 2001
    Location
    US
    Posts
    43
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: *error * ... already connected

    Hi this is the script that i am using now but i still am getting the same error. ....


    [-] testcase DBTest () appstate none
    [ ]
    [ ] // This test uses the functions in DBTester
    [ ] // to directly access an ODBC database
    [ ]
    [ ] INTEGER recordid, hID
    [ ] STRING sDeptName
    [ ] HDATABASE hdbc
    [ ] HSQL hstmnt
    [ ]
    [ ] // connect to Powersoft Demo DB
    [ ] hdbc = DB_Connect ("dsn=postgresql;PWD=jer2911;UID=fp")
    [ ]
    [ ] // retrieve info from Department table
    [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM aduser")
    [ ]
    [-] // process the information that came back
    [ ]
    [-] print ("Here's the info in the Department table:")
    [ ] print (DB_FetchNext (hstmnt, recordid))
    [ ]
    [ ] print ("Dept: {recordid}")
    [ ]
    [ ] // release resources (unneeded really
    [ ] // because immediately followed by disconnect)
    [ ] DB_FinishSQL (hstmnt)
    [ ]
    [ ] // disconnect
    [ ] DB_Disconnect (hdbc)
    [ ]

    please help ..... i am stuck because of this connect error.


    P.T
    P.T.

  7. #7
    Super Member
    Join Date
    Jul 1999
    Location
    Rancho Santa Margarita, CA
    Posts
    1,439
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: *error * ... already connected

    PT,

    From your sample testcase, I still don't see how you get an error on hdbc being not a variable. Your code looks fine to me except that I always have UID before the PWD in my sConnectString (I don't know if it makes a difference in Powersoft/Linux environment).
    For the other error "already connected", my guess is it seems like you run your testcase and the DB_Connect () got executed, then you get some kind of error before the DB_Disconnect () got executed (in short, the testcase never completed all the way through), then you run your testcase again and you get "...already connected..." error.

    Suggestion:
    Before running your testcase, check (outside of SilkTest) and see if you are really connected already or not. There are many DB tools out there that you can use.
    Or, in the beginning of your testcase, issue a DB_Disconnect () (possibly inside a do..except) before you issue the DB_Connect (). If you still see the "..already connected.." error, then maybe someone in your office is trying to play with you by connecting to the same database using the same ID and Password that you use and doing this when he/she knows that you are about to run your testcase ( :


    [This message has been edited by Gilbert (edited 03-22-2001).]

  8. #8
    Member
    Join Date
    Nov 2000
    Location
    Tampa, FL USA
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: *error * ... already connected

    try putting do...except around each statement to track where the exact problem is.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:44 AM.

Copyright BetaSoft Inc.