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

What all different approaches can be used for designing an automation solution?

871


What is tsl?

995


Can any one give information on "Content Disposition" in TEST COMPLETE automation tool? mail me to pdamarakonda@smart-bridge.co.in call me to 09849423932

1981


hi to all, if we open a browser(for ex. yahoomail.com) using navigate command. the cursor by default focussing on the 'yahoo id' html edit box. how to get the label(ie.,yahoo id) of that html edit box using descriptive program. here we should not use identify tool to get the property,thtml editbox method. by tracing the cursor position we have to get the label name. is it possible? please let me know.

2168


Explain me what is the difference between setspeed() and sleep() methods?

1016


What is the difference between close and quit command?

1009


What you know about table-driven testing?

1012


What generally is the structure of a framework?

976


Tell us what is the alternate way to click on login button?

978


How does load testing work for websites?

1089


Do you know the difference between close and quit command?

916


Do you know what is selenese?

1035


On Test Complete I recorded some keyword test. while I'm running the batch test, if one test case failed, then how test complete skip the failed test case and again continue to run the test case? please provide some way to resolve this issue.

1930


How would you test your own element locator?

961


Elaborate the scripting standard while executing testing

951