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
Tell us which package can be imported while working with webdriver?
What u mean by infrgistics control (What is infrgistics Controls)?
explain add in manager and virtual object wizard in winrunner
Explain what is the hybrid framework?
Tell me what is the firefoxdriver, class or an interface? And which interface does it implement?
What are the different types of locks in mainframe?
What are the points that are covered while planning phase of automation ?
Does every software project need testers?
Simplify the term defect severity.
Elaborate the fields in bug report in automated testing
What are the things that one should consider for selecting a project for test automation? For example, stability, etc.
What is the purpose of deselectall() method?
What is data - driven automation?
What is junit annotation?
Tell us the line of code webdriver driver = new firefoxdriver();.?