18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

close the db connection

vazidvazid Members
edited November -1 in Sahi - Open Source
Hi,

Is there any way to close the DB connection in sahi?

Regards,
Vazid

Comments

  • rksrks Members
    I guess that is a valid issue. I looked into the src code and it seems that connections are not being closed in db related calls.
  • That is a terrible flaw.....this is causing me so much heart ach. Sahi is not usuable for dynamic data change checking without breaking the script into more script per SQL query that needs to be done.

    Example:

    I will go to a web page enter a new user to something. If I have a query that looks up the new entry and one to delete it for clean up. But because sahi likes to build up and run queries lots even if there is only two it causes this problem.

    I make the new user I got to check it but when sahi runs the get query it immediatly runs the clean up query deleting any chance of me performing a check and clean up within the same script.
  • vazidvazid Members
    Hey and one more thing..i'm not sure why this is happening,
    I've created a DB function like

    function DBconn()
    {
    var $driver="com.hxtt.sql.excel.ExcelDriver";
    var $Loginfile=<path of the file>;
    var db=_getDB($driver,$Loginfile, "username", "password");
    var $rs =[];
    $rs=db.select("select * from Sheet1");
    return($rs);
    }

    And im trying to call this function in another scritps of mine..but when I try to set my web page for the play back sahi window [sahi cmd prompt] shows these below lines again n again even while running and i found it bit strange, even if i stop the script and just work with my application still these lines keep scrolling in sahi cmd prompt

    Driver: com.hxtt.sql.excel.ExcelDriver
    JDBC URL: jdbc:excel:/<path of the file>
    Username: username
    Password: password
    SQL: select * from Sheet1

    I believe this is due to not clearing of cache or some thing which im not sure....I've seen posts of similar problems..
    But using this db connection thing i'm facing lot of problems in running scripts..

    if i hard code values in scritps and run them then the scripts runs fine but when i apply the above said db function then the script stops in between with no error being displayed...I have to then restart sahi.bat

    Has any one has any work around for this prob??? Please let me know....

    Rgds.
  • rksrks Members
    Yes this is a issue and I have also faced this. I overcame this by wrapping the function call in a _call() method.
Sign In or Register to comment.