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
If I have given names to different DataTable columns and those column names are stored in a variable, then passing that variable to the datatable how can i Enter different values in those columns listed in that variable?? Please explain me with an example.I am not getting it.
script to check availibility of mail in yahoo mail box in qtp
Tell me which web driver implementation is the fastest?
What is the deference between automation tools and management tools?
What are Keyword and Data driven frameworks in Selenium RC
What factors determine the effectiveness of automation testing?
Tell me what is tsl? What 4gl is it similar too?
Explain me how to check if an element is visible on the page?
What issues come up in test automation, and how do you manage them?
Tell us what is the difference between single slash (/) and a double slash ( //) in xpath?
How to integrate Rational functional Tester with Rational Quality manager. Can anyone provide the details steps giving explaination with examples.
How to Rcognize the Objects in the Web Page Dialog Using QTP
how to re-install QTP 11.0 trial version
List out some of the automation tools which could be integrated with selenium to achieve continuous testing.
hi every one this is ashok pls any one give answer me pls question is while testing with selenium after giving id user name and password , the inbox will be open , how to handle this one