18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Unable to connect to db without using Sahi API
I am using Sahi 4.5.1
ojdbc6.jar is placed to sahiHome\extlib\db folder
"set SAHI_EXT_CLASS_PATH=%SAHI_HOME%;C:\sahi_pro\extlib\db\ojdbc6.jar;" is added to SahiHome\bin\dashboard.bat at :startsahi
And FYI _getDB is working fine with the above settings but the following function which directly fetches the db data without using Sahi API is failed. Please have a look
function Execute_Query($Sql)
{
try
{
java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");
var $DB = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@OraDBServer01:1521:OraDB" , "User01","Sahi678");
_alert($DB) \\ alerts undefined;
$Stmt = $DB.createStatement();
$RS = $Stmt.executeQuery($Sql);
return ($RS);
}
catch ($e)
{
_debug($e);
}
finally
{
}
}
//function call:
var $Records = Execute_Query("select * from users");
//$Records retrieved is null
Should i have to do any changes in sahi config files
ojdbc6.jar is placed to sahiHome\extlib\db folder
"set SAHI_EXT_CLASS_PATH=%SAHI_HOME%;C:\sahi_pro\extlib\db\ojdbc6.jar;" is added to SahiHome\bin\dashboard.bat at :startsahi
And FYI _getDB is working fine with the above settings but the following function which directly fetches the db data without using Sahi API is failed. Please have a look
function Execute_Query($Sql)
{
try
{
java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");
var $DB = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@OraDBServer01:1521:OraDB" , "User01","Sahi678");
_alert($DB) \\ alerts undefined;
$Stmt = $DB.createStatement();
$RS = $Stmt.executeQuery($Sql);
return ($RS);
}
catch ($e)
{
_debug($e);
}
finally
{
}
}
//function call:
var $Records = Execute_Query("select * from users");
//$Records retrieved is null
Should i have to do any changes in sahi config files
Answers
Steps:
1. Create a java class file and export it as a jar file
2. place the jar file in sahi_userdata_dir\extlib folder (create extlib folder if not exists)
3. set the jar file path in Start_Dashboard.bat for "SAHI_EXT_CLASS_PATH" variable as shown below
SET SAHI_EXT_CLASS_PATH=%SAHI_USERDATA_DIR%\extlib\testdb.jar;
4. Restart sahi and call the java methods to execute db queries
Thanks,
Vinoth