Install my sql
In selenium, write code as
import java.sql.*
public class Db_connect{
connection conn=null;
String url= jdbc:mysql://localhost:3306/";
String DBName="Test" (Table name)
String driver="com.mysql.jdbc.Driver";
String username="kkjkj"
String password="fff";
try{
class.forName(driver).newInstance(); //create object of instance of driver
conn=DriverManager.getconnection(url+dbname+username,[password) //get connection
Statement stmt= conn.createstatement();
resultset s= stmt.executequery("select * from users");
rs.next();
syso(rs.getstring(1);
while(rs.next)
syso(rs.getstring(1)
Prepare statement pp=conn.prepare statement
pp.setstring(1,"p");
resultset rs3=pp1.executequery();
}catch(Exception e)
{
finally
conn.close();
In selenium, write code as
import java.sql.*
public class Db_connect{
connection conn=null;
String url= jdbc:mysql://localhost:3306/";
String DBName="Test" (Table name)
String driver="com.mysql.jdbc.Driver";
String username="kkjkj"
String password="fff";
try{
class.forName(driver).newInstance(); //create object of instance of driver
conn=DriverManager.getconnection(url+dbname+username,[password) //get connection
Statement stmt= conn.createstatement();
resultset s= stmt.executequery("select * from users");
rs.next();
syso(rs.getstring(1);
while(rs.next)
syso(rs.getstring(1)
Prepare statement pp=conn.prepare statement
pp.setstring(1,"p");
resultset rs3=pp1.executequery();
}catch(Exception e)
{
finally
conn.close();