Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Tell us which package can be imported while working with webdriver?

1007


What u mean by infrgistics control (What is infrgistics Controls)?

2062


explain add in manager and virtual object wizard in winrunner

2102


Explain what is the hybrid framework?

952


Tell me what is the firefoxdriver, class or an interface? And which interface does it implement?

848


What are the different types of locks in mainframe?

902


What are the points that are covered while planning phase of automation ?

1098


Does every software project need testers?

949


Simplify the term defect severity.

866


Elaborate the fields in bug report in automated testing

951


What are the things that one should consider for selecting a project for test automation? For example, stability, etc.

1953


What is the purpose of deselectall() method?

941


What is data - driven automation?

2609


What is junit annotation?

987


Tell us the line of code webdriver driver = new firefoxdriver();.?

891