In selenium testing how to connect with database , any one
pls give the entire information
Answer Posted / sandip
public class dbconnection
{
public static void main(String args[])
{
String email;
String dbUrl = "jdbc:mysql://localhost:3306/test"; //This
URL is based on your IP address
String username="username"; //Default username is root
String password="password"; //Default password is root
String dbClass = "com.mysql.jdbc.Driver";
String query = "Select email from users where user_id = 1;";
try
{
Class.forName(dbClass);
Connection con = DriverManager.getConnection
(dbUrl,username,password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
{
dbtime = rs.getString(1);
System.out.println(email);
} //end while
con.close();
} //end try
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
} //end main
} //end class
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Do you know how to check if a button is enabled on the page?
Tell us how can you create html test report from your test script?
what is the difference between keyword driven frame work and data driven frame work.
Can any one give me the script for drag and drop or setselection functions ?like in a not pad i want to select 5 lines
Please explain what is a relative xpath?
Why do you want to keep this kind of information in a separate file and not directly in the code?
What are the advantages of test automation?
Tell me what are pros and cons of automating tests at ui layer?
List of Test Management Tools??Is Quality Center Test Management tools
Explain me what is testng and why is it better than junit?
hi i would like to know is there any training institue for Calabash,robotium and ui automator in hyderabad...urgent
Do you know what is the purpose of creating a reference variable- 'driver' of type webdriver instead of directly creating a firefoxdriver object or any other driver's reference in the statement webdriver driver = new firefoxdriver();?
How does load testing work for websites?
Give some examples for defect management tools?
How do you select which automation tool is best suited for you?