Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Monday, February 21, 2011

How to do a DDT having a Db connection in selenium

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import java.sql.*;
import javax.sql.*;
import java.io.*;
public class contact extends SeleneseTestCase

public void setUp() throws Exception
// add details of browser & other details

public void testContact() throws Exception {
System.out.println("Connecting to the database");
String url="jdbc:mysql://localhost:/main.jsp";
Class driverClass = Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection(url,"", "");
System.out.println("Connected to the database");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from emp_account");
ResultSetMetaData rsmd = rs.getMetaData();
int columns = rsmd.getColumnCount
while (rs.next())
for (int i = 1; i < columns; i++)
System.out.print(rs.getObject(i + 1)+" |");
System.out.println(" ");
automationwithselenium.blogspot.com-Google pagerank and Worth