Here is the code for the connection to a mysql Database using Microsoft SQL Server JDBC driver.
public void DBtest() throws Exception
{
// Load Microsoft SQL Server JDBC driver.
Class.forName(“com.mysql.jdbc.Driver”);
// Prepare connection url.
String url = “jdbc:mysql://localhost/TEST_DB”;
// Get connection to DB.
Connection con = DriverManager.getConnection(url, “root”, “admin”);
// Create statement object which would be used in writing DDL and DML
// SQL statement.
Statement stmt = con.createStatement();
// Send SQL SELECT statements to the database via the
Statement.executeQuery
// method which returns the requested information as rows of data in a
// ResultSet object.
ResultSet result = stmt.executeQuery(“select email from user”);
if (result.next()){
// Fetch value of “email_address” from “result” object.
String emailaddress = result.getString(“email”);
// Use the fetched value to login to application.
selenium.open(“/”);
selenium.windowMaximize();
selenium.type(“login_email”, emailaddress);
}
}
Here is an example that shows you how you can connect to the database and how to execute the SQL queries in the selenium C# scripts.
In this example I am connecting the SQL server by passing the server name, username password and the database name. I then execute the SQL command “select Employee_no from employee where deptno =100″
Database Migrating Testing verifies the following
1) Visibility of all business data in respective fields in migrated system
2) History data links to other system
3) Status of various business entities in migrated system.
e.g. a. Task which have completed status should be displayed completed in migrated system
b. Review history of any documents
c. Previous transaction data for business entities
d. Meeting and conference records in migrated system
4) Future dates sets for some specific fields should be displayed in same way in migrated system
5) User Accounts and Groups data in migrated system
SQL Injection is also know as HTML Injection. Passing SQL queries in the Addreess bar with the intend to break out the system. This is to check the site vulnerability. You may think while we doing the SQL injection how we will find out the site is vulnerable or not.
While passing this SQL injection. if we found any of this below means its be a bug
* should not display the records(index.asp?–Select * from sales). it should not display the sales record in the front end page
*should not show any Database name
* should not show any table name
* should not show any column name
* should not show any constraints(Primary key/foregin key names)