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.
Connecting database
Hi,
Can you please provide me the code to connect to oracle 10g database
I want to connect to database and retrieve a query's result in to a variable and then check the retrieved data with that of expected result.
Waiting eagerly for reply.
Thanks,
Samsirsameer.
Can you please provide me the code to connect to oracle 10g database
I want to connect to database and retrieve a query's result in to a variable and then check the retrieved data with that of expected result.
Waiting eagerly for reply.
Thanks,
Samsirsameer.
Comments
var $rs = db.select("select serial_number from device where ping_rate=1000); //it will return the device whose ping rate is 1000 milliseconds
_assertEqual("abc", $rs[0]["PING_RATE"]); //verifying whether the retrieved device name is "abc" or not
Please let me know the what is the driver that needs to be placed in Sahi and where exactly i need to place it.
Thanks
Samsirsameer.
search for classes12.jar in your oracle installation. It will be in ../jdbc/lib/ folder of your oracle client installation. You can either use the same path in your sahi.bat or you can copy this jar file in sahi/extlib/
then edit your sahi.bat to add:
-classpath ../extlib/classes12.jar;
My sahi.bat looks like this: change<my oracle path> to whereever you put your file
Regards,
Pankaj
I ahve copied the classes.12.jar file in to C/sahi/extlib/ directoty and edited the classpath.
My class path looks like
SET EXT_CLASS_PATH=;
REM eg. SET EXT_CLASS_PATH=%EXT_CLASS_PATH%;..\extlib\db\mysql-connector-java-5.0.4-bin.jar
SET SAHI_CLASS_PATH=..\lib\sahi.jar;..\extlib\rhino\js.jar;..\extlib\apc\commons-codec-1.3.jar
REM SET MOZ_NO_REMOTE=1
java -classpath %EXT_CLASS_PATH%;%SAHI_CLASS_PATH% net.sf.sahi.Proxy
java -classpath c:\sahi\extlib\10.2.0.3\classes12.jar;../lib/sahi.jar net.sf.sahi.Proxy
I used the following SCRipt,
Script:
function database() {
try {
var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@192.168.161.5:1521:oracle", "chicago7", "chicago7");
2 var $rs = db.select("select ping_rate,backup_enabled from device where serial_number='SP_531_Serial'"); //it will return the device whose ping rate is 1000 milliseconds
3 _assertEqual("5000", $rs[0]["PING_RATE"]); //verifying whether the retrieved device name is "abc" or not
4 _assertEqual("0", $rs[0]["backup_enabled"]); //verifying whether the retrieved device name is "abc" or not
5
6 _debugToFile("TCS:LOGIN006 PING RATE and BACKUP IS VERIFIED PASSED", "C:\sahi\SAHIPROJECT\Logs\Log.txt");
}
catch(e) {
_debugToFile("TCS:LOGIN006 PING RATE and BACKUP IS Incorrect PASSED", "C:\sahi\SAHIPROJECT\Logs\Log.txt");
}
}
Actual Result: JSERROR:SyntaxError: Syntax error
Expected Result: The script should pass
Please help me in this regards
Thanks,
Samsirsameer.
Please reply....
I sucessfully completed the configuration part and i run the script, but i will not ensure wheather it is intracted with Database, becasue i checked the condition with both positive and negative approach but i got the same result(pass) for both. please guid me how to ensure the database.
I am using sql server 2005 in my company.