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

How do you decide which tool you have to use?

0 Answers  


What are the types of framework used in software automation testing ?

0 Answers  


What is the difference between automation tools and management tools?

0 Answers  


all clients are using at once if any problem raise?

0 Answers   Mind Tree,


How to decide the tool that one should use for automation testing in their projects?

0 Answers  


i am looking for HP QTP automated testing software, do you offers reselling this software or should i directly purchase with HP

1 Answers   HP,


what is meant by keyboard driven test?

3 Answers  


HOW CAN WINRUNNER AND TEST DIRECTOR CONNECTED TO THE DATABASE AND WHAT R THE OPTIONS?

0 Answers   SPC Systems,


Kindly let me know how to setup JMeter for functionality testing of a Web application.. The apache help doc is good but i m little confused with it... :(

0 Answers   Telelogic,


Write a query to find second highest salary of an employee.

72 Answers   ABC, Cognizant, MegaSoft, Netwin Infosolutions, Nippon, Polaris, Satyam, SGS, TCS, Verisoft,


What testing activities you may want to automate?

0 Answers  


How can the user get a text of a web element?

0 Answers  


Categories