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.

How to access SQL server 2005 database from SAHI script.

mohit198mohit198 Members
edited November -1 in Sahi - Open Source
Hi All,

I am using SQL server 2005 database in my project.
Please let me know what are basic setup required for accessing database from SAHI script.
Like driver or any othre supporting prerequiset.

I have installed Microsoft JDBC driver for SQL 2005.

Please help ...

With Regards,
Mohit

Comments

  • Hi All,

    code:
    //Function for retrieve data from DB
    function getDataFromDB(){
    $Query = "select * from taskmaster";
    var $db1 = _getDB("com.microsoft.sqlserver.jdbc.SQLServerDriver","jdbc:sqlserver://172.16.221.180:8080;databaseName=Billing;user=mohit;password=test200","mohit","test200");
    $res = $db1.select($Query);
    var $length1 = $res.length;
    return $length1;
    }

    $len1 = getDataFromDB();
    _alert($len1);

    Error:

    exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 172.16.221.180, port 8080 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError

    Please help.

    Mohit
  • Hi All,

    Now system is giving below issue.

    Code:
    var $db1 = _getDB("com.microsoft.sqlserver.jdbc.SQLServerDriver","jdbc:sqlserver://172.16.221.175\\mnettestsvr:1433;databaseName=Glb_TimeSheetBilling","mohit","test200$");

    Error:

    exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'mohit'. The user is not associated with a trusted SQL Server connection.

    Please let me know if there is any issue with code.

    Please help to resolve above issue.

    Thanks,
    Mohit
  • Hi All,

    Its working fine now. i have removed port from jdburl.


    code:
    //Function for retrieve data from DB
    function getDataFromDB(){
    $Query = "select * from taskmaster";
    var $db1 = _getDB("com.microsoft.sqlserver.jdbc.SQLServerDriver","jdbc:sqlserver://172.16.221.180;databaseName=Billing;user=mohit;password=test200","mohit","test200");
    $res = $db1.select($Query);
    var $length1 = $res.length;
    return $length1;
    }

    $len1 = getDataFromDB();
    _alert($len1);
Sign In or Register to comment.