Reading the data from CSV file using JDBC Connection.

760 views
Skip to first unread message

Smitha

unread,
Nov 21, 2017, 12:41:38 PM11/21/17
to PrimaTest Automation
Hello,

Please help me on this issue-

1) I have added csvjdbc-1.0-34.jar file in the external libraries.
2) I have 5 parameters added for this action-
3) I have a ReadCsvFile file to read the data from csv file and run the query.
4) Elements.java defines the identifiers that need to be passed.
5 ) Sendkeysdemo.java files defines the value that need to be passed for the element/identifiers.

Issues are highlighted in bold letters below. Please guide me to achieve this scenario is RW.

public class ReadCsvFiles {
public static String actual_objId;
public static String actual_objValue;
public static String actual_objType;
public static ReadCsvFiles CsvFiles(HashMap<String, Object> params){
    
        String Objname = (String)params.get("Obj_Name");
        String platform = (String)params.get("Platform");
        System.out.println(Objname+"***********"+platform);   //Parameter values are printing null for both of them
        try
        {
            //Class.forName("org.relique.jdbc.csv.CsvDriver");
        Connection conn = DriverManager.getConnection("jdbc:relique:csv:D:Path of the file");
        java.sql.Statement stmt = conn.createStatement();
        ResultSet results = stmt.executeQuery("select * from testdata WHERE Obj_Name = Objname AND Platform = platform");
            results.next();
            actual_objId = (String) results.getString(3);
            actual_objType = (String) results.getString(4);
            actual_objValue = (String) results.getSting(5);  // Getting error for this line. however i dont have any errors on eclipse for this line, Not sure what is wrong. Cannot find symbol error
            
         }catch(Exception e)
         {
            e.printStackTrace();
         }
return null;
}
}

public class Elements{
   
    static WebDriver driver = null;
  
    public static WebElement find(WebDriver driver){
        
      String ID = ReadCsvFiles.actual_objId;
      String obj_type = ReadCsvFiles.actual_objType;
        
  WebElement foundElement = null;
        
         if (ReadCsvFiles.actual_objType  == "XPath"){   
             foundElement = driver.findElement(By.xpath(ID));  //(just added one identifier example.
         }else{
             return null;
            // System.out.Println("Enter the value identifiers");
         }
}

public class sendkeysdemo{
    
    public void run(HashMap<String, Object> params){
        
      WebElement element = Elements.find(openBrowser.driver);
        ReadCsvFiles file = ReadCsvFiles.CsvFiles();
     
      //String text = ReadCsvFiles.actual_objValue;
            String Text = (String) params.get("Text");
        
        if(Text != null)
        {
            element.sendKeys(file.actual_objValue);
        }
        else
            {
            return;
        } 
    }  
    }




Reply all
Reply to author
Forward
0 new messages