Saturday, 25 May 2019

UFT: Using Class File in UFT Action

'###CLASS FILE

ExecuteGlobal "Dim Reporter"
Set Reporter = New HtmlReporter


Class HtmlReporter
 
Public Sub Class_Initialize(  )
   
    print "started"
   
    Systemutil.CloseProcessByName "iexplore.exe"
    Systemutil.Run "iexplore.exe"
End Sub
   
'When Object is Set to Nothing
public Sub Class_Terminate(  )
       
    Systemutil.CloseProcessByName "iexplore.exe"
   
    print "ended"
End Sub
   
End Class



'###ACTION


msgbox datatable.Value("Value")


'#DATATABLE
Value
1
2
3

Saturday, 11 May 2019

ADODB my SQL Connection with VbScript

Function test()

On Error Resume Next

Set obj = CreateObject("ADODB.Connection")
Set obj1 = CreateObject("ADODB.RecordSet")
Dim dbquery
dbquery = "INSERT INTO test (firstname,lastname) VALUES ('neha','deshmukh');"

obj.Open "Server=db4free.net;Data Source=mysql; Database=sumit1234; User=sumit1234; Password=sumit1234;"

MsgBox obj1.State & ""

MsgBox Err.Description
obj1.Open dbquery, obj

MsgBox Err.Description

obj.Close
obj1.Close
Set obj1 = Nothing
Set obj = Nothing


End Function

Thursday, 9 May 2019

JDBC: My Sql Insert Statement

package mysqlconnect;

import java.sql.*; 
class Insert{ 
public static void main(String args[]) throws SQLException, ClassNotFoundException{ 
   
Class.forName("com.mysql.jdbc.Driver"); 
Connection con=DriverManager.getConnection( 
"jdbc:mysql://db4fre.net/sumit1234","sumit1234","sumit1234"); 
//here db4fre.net/sumit1234 is server/database name, sumit1234 username and sumit1234password 
Statement stmt=con.createStatement(); 
String begin = "INSERT INTO `test`(`firstname`, `lastname`) VALUES ";

for (int i = 2000; i < 3001; i++) {

begin = begin + "(" + i + "," + (i + 10) + ")" + ",";
}

begin = begin.replaceAll(",$", ";"); //As we want ; after last value
stmt.executeUpdate(begin); //INSERT DELTE UPDATE needs executeUpdate
   
con.close(); 



}

JDBC: Mysql Select Statement

package mysqlconnect;

import java.sql.*;
class TestConnection{
public static void main(String args[]){

try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://db4fr.net/sumit1234","sumit1234","sumit1234");

// here db4fre.net/sumit1234 is server/database name, sumit1234 username and sumit1234password

Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from test");
while(rs.next())

System.out.println(rs.getString(1)+"  "+rs.getString(2));  //BE CAREFUL HERE . DIFFERENT FIELDS HAVE DIFFERENT datatype
//System.out.println("reached inside while");

con.close();  //Closing Connection

}catch(Exception e){ System.out.println(e);}
}
}



'################OUTPUT##################################################

sumit  raut
1  11
2  12
3  13
4  14
5  15
6  16
7  17
8  18
9  19
1  11
2  12
3  13
4  14
5  15
6  16
7  17
8  18
9  19
2000  2010
2001  2011
2002  2012
2003  2013
2004  2014
2005  2015
2006  2016
2007  2017


Spring Boot : Exception Handler 14