Generally We don’t have to Test entire database of our application.To my knowledge, We use Selenium to test the Database whether data given in the front end(UI) is as same as the data present in the Database(Back End).
Note: We don’t do negative testing in database.
Here i am using MySql to test the database.
You need to Download Java.sql jar and configure database in your system. I’ll explain database configuration in Upcoming posts.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
public class testng_8
{
public WebDriver fd;
@Test
public void method_sql() throws Exception
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection cn=DriverManager.getConnection(“jdbc:mysql:wombat”, “myLogin”, “myPassword”);
Statement st=cn.createStatement();
ResultSet rs= st.executeQuery(“select * from emp”);
try {
while (rs.next())
{
System.out.println(rs.getString(0));
}
cn.close();
}
catch (Exception e)
{
System.out.println(“invalid”);
}
}
}
Note: We don’t do negative testing in database.
Here i am using MySql to test the database.
You need to Download Java.sql jar and configure database in your system. I’ll explain database configuration in Upcoming posts.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
public class testng_8
{
public WebDriver fd;
@Test
public void method_sql() throws Exception
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection cn=DriverManager.getConnection(“jdbc:mysql:wombat”, “myLogin”, “myPassword”);
Statement st=cn.createStatement();
ResultSet rs= st.executeQuery(“select * from emp”);
try {
while (rs.next())
{
System.out.println(rs.getString(0));
}
cn.close();
}
catch (Exception e)
{
System.out.println(“invalid”);
}
}
}
Casino Hotel - Mapyro
ReplyDeleteThe Casinos at 경주 출장안마 Mohegan Sun in Uncasville, CT offers more 광명 출장마사지 than 2,300 gaming machines. 광양 출장마사지 It 목포 출장샵 features a casino floor that's more than 영천 출장마사지 3,000 slot machines