Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How do I pass values from database to the UI using Java? I am getting error column not found ?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I pass values from database to the UI using Automation Selenium WebDriver with Java? I am getting error that com.mysql.jdbc.JDBC42 ResultSet cannot be cast to java.util.ArrayList? I am stuck please, help.

I have been trying for 2 days to make this code work. I am unable to figure it out. I am getting error message com.mysql.jdbc.JDBC42ResultSet cannot be cast to java.util.ArrayList.   I am not sure what I am doing wrong. I guess the object cannot be a String?

Basically, In this case I have firstName and lastName which are passed via the database to the UI. I want to pass those values to my test case. I do not want to hard code inside the code files.  How can I achieve this?  Currently, I have a table with 2 columns and one column is firstName and second column is lastName.




I want to Iterate through the database and pick these values wherever I want. SendKeys.  



Here is my test case file where I will execute the test case 101 - see code below.




Here is my DB file where I am getting the values from database and returning it to the test case 101 - see code below.  I have omitted the username and password information.




I am completely stuck with this. I really need help. Please, let me know how I can achieve this concept. Once I get the basics I will utilize the same file and the same concept for all 200 test cases.  Since in Excel Sheet we can use 2D array to pass the values to the test case. Why can't we use the same concept 2D array to pass the values from database to UI. I am thinking maybe in via database it is a different concept.

Thanks
db_test_data.PNG
[Thumbnail for db_test_data.PNG]
 
C Dome
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have updated the code. see below.

C Dome wrote:How do I pass values from database to the UI using Automation Selenium WebDriver with Java? I am getting error that com.mysql.jdbc.JDBC42 ResultSet cannot be cast to java.util.ArrayList? I am stuck please, help.

I have been trying for 2 days to make this code work. I am unable to figure it out. I am getting error message com.mysql.jdbc.JDBC42ResultSet cannot be cast to java.util.ArrayList.   I am not sure what I am doing wrong. I guess the object cannot be a String?

Basically, In this case I have firstName and lastName which are passed via the database to the UI. I want to pass those values to my test case. I do not want to hard code inside the code files.  How can I achieve this?  Currently, I have a table with 2 columns and one column is firstName and second column is lastName.




I want to Iterate through the database and pick these values wherever I want. SendKeys.  



Here is my test case file where I will execute the test case 101 - see code below.




Here is my DB file where I am getting the values from database and returning it to the test case 101 - see code below.  I have omitted the username and password information.




I am completely stuck with this. I really need help. Please, let me know how I can achieve this concept. Once I get the basics I will utilize the same file and the same concept for all 200 test cases.  Since in Excel Sheet we can use 2D array to pass the values to the test case. Why can't we use the same concept 2D array to pass the values from database to UI. I am thinking maybe in via database it is a different concept.

Thanks

 
Sheriff
Posts: 26798
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

C Dome wrote:I am getting error message com.mysql.jdbc.JDBC42ResultSet cannot be cast to java.util.ArrayList.



Well, that's different from the title of this thread. On the other hand I can't see why you would be getting that error message from the code you posted. So, could you post the entire stack trace which you got from the most recent version of the code you posted here?
 
C Dome
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

C Dome wrote:I am getting error message com.mysql.jdbc.JDBC42ResultSet cannot be cast to java.util.ArrayList.



Well, that's different from the title of this thread. On the other hand I can't see why you would be getting that error message from the code you posted. So, could you post the entire stack trace which you got from the most recent version of the code you posted here?



Hi,

Thank you for replying I am new to this site. Sorry about the confusion. I tried my best to edit the post. For some reason I don't have the option to edit posts. Can you please, give me access to edit the posts.  

As for my Issue.  I found a solution.  Here is my solution below.


I just used a do while loop to Iterate and fetch the data from the database table rows.   Thank you for your support. I really appreciate it.


See solution code below.




Here is how I resolved my issue. I used a do while loop in my test case and It was able to fetch all the data from all rows and Iterate it in my webpage.

Here is the code below.

FacebookTest code file:





Here is my DBTestData file:



Thank you. Hope this helps anyone else looking for this solution.
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting your solution!

For some reason I don't have the option to edit posts. Can you please, give me access to edit the posts.  


CodeRanch doesn't allow new members to edit posts.  If you want something specifically edited and it doesn't make the thread confusing, ask a Marshal or Sheriff (like me) to edit your post for you.

One good way of preventing the need to edit your post is to use the Preview button first, just to the left of the Submit button.
 
reply
    Bookmark Topic Watch Topic
  • New Topic