In selenium testing how to connect with database , any one

pls give the entire information

Answers were Sorted based on User's Feedback



In selenium testing how to connect with database , any one pls give the entire information..

Answer / guest

Just create a java class for jdbc connection, call it when
you need to connect to database. to crate a jdbc connection
class please follow
http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml

Is This Answer Correct ?    2 Yes 0 No

In selenium testing how to connect with database , any one pls give the entire information..

Answer / 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

More Automation Testing AllOther Interview Questions

What is Database Testing?

5 Answers   Covansys,


Please explain how to perform load-testing?

0 Answers  


Can test automation improve test effectiveness?

1 Answers  


What types of documents would you need for QA, QC, and Testing?

1 Answers  


Could anybody send me the document on how to re install QTP 9.0 after the evalution period (14 days). It will expire within 3 days. Thabks in advance.

4 Answers  






How can you switch back from a frame?

0 Answers  


What are the important modules of an automation testing framework?

0 Answers  


Explain me how do you send enter/tab keys in webdriver?

0 Answers  


Tell me how could the web element attributes be inspected in order to use them in different locators?

0 Answers  


Where do we get the QTP and Load runner softwares CDs ( Original ) in chennai

0 Answers  


notice the distinction between data driven testing and retesting?

0 Answers  


How will you choose a tool for test automation?

0 Answers  


Categories