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 I execute the Stored Procedure

amol.likhiteamol.likhite Members
edited November -1 in Sahi - Open Source
Hi,

How I Execute the Stored Procedure using SAHI Scripts.

Please help me.

Amol

Comments

  • Hi,

    Please see below code.
    function ExecuteProcedure(sql)
    {
    var $db = _getDB ("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/kubbe", "root", "silicus");
    $db.execute(sql);
    }

    function selectUserData()
    {
    var $returnedData;
    var $sql = "EXEC kubbe.selectuser ";
    ExecuteProcedure($sql);
    }

    selectUserData();

    But it is not working.

    Amol
  • narayannarayan Administrators
    Amol,

    Sahi does not currently have in built support to execute stored procedures.

    You can do this to execute your sp.
    var $driverName = "com.mysql.jdbc.Driver";
    var $jdbcurl = "jdbc:mysql://localhost:3306/kubbe";
    var $username = "root";
    var $password = "silicus";
    
    var $connection = null;
    try {
        java.lang.Class.forName($driverName);
        $connection = java.sql.DriverManager.getConnection($jdbcurl, $username, $password);
        var $callableStatement = $connection.prepareCall("{call kubbe.selectuser}");
        $callableStatement.execute();
    } catch ($e) {
        $e.printStackTrace();
    } finally {
        if ($connection != null){
            try{
                $connection.close();
            }catch($e2){
                $e2.printStackTrace();
            }
        }
    }
    
  • Hi Narayan,

    Solutions works fine.
    Thanks for the help.

    Amol
This discussion has been closed.