Javascript Code To Check The Connection Between Orchestrator Server And Database, Also To Check The Execution Time Of Any Query

How to check connection and execution time of any query from Orchestrator server to database?

The below ready-made javascript code can be run in console tab of any browser from orchestrator server to check the connection between orchestrator and database server and execution time of any query from orchestrator server to database.

  • The connection time can be checked by using ODBC connection also. However, the advantage in using this method is the measuring the execution duration of any query from orchestrator server to database server(it may differ if we directly run some query in database as the connection takes some time to be established)
var d = new Date();
var n = d.getTime();
console.log(n)
var objConnection = new ActiveXObject("adodb.connection");
var strConn = "driver={sql server};server=Servername;database=DatabaseName;uid=Username;password=Password";
objConnection.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var strQuery = "SELECT * FROM Logs";
rs.Open(strQuery, objConnection);
rs.MoveFirst();
while (!rs.EOF) {
document.write(rs.fields(0) + "        ");
document.write(rs.fields(1) + "        ");
document.write(rs.fields(2) + "         ");
document.write(rs.fields(3) + "         ");
document.write(rs.fields(4) + "
");
rs.movenext();
}
var exetime = d.getTime();
console.log(exetime)
var diff = exetime - n;
console.log(diff);

Note:
  • ActiveXObject is supported only in internet explorer. Hence this code will work only in internet explorer.
  • Provide the database details in the code - server name, database name, username and password.
  • The query used in the code can be modified as per the requirement.

Refer the below screenshot: