Collections and DBConnections and Grid
HashMap:
public class CollectionsHashMap {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashMap hs = new HashMap();
HashMap hsNew = new HashMap();
hs.put(3, "Gaddam");
hs.put(1, "Santosh");
hs.put(2, "kumar");
System.out.println(hs);
System.out.println("===");
hs.remove(2);
System.out.println(hs);
System.out.println("===");
hs.put(3, "Gaddams");
hs.put(4, "");
hs.put(5, "");
hs.put(null, "its me null key");
hs.put(null, "its me null keys");
System.out.println(hs);
Set hp = hs.entrySet();
Iterator ip = hp.iterator();
while(ip.hasNext()) {
Map.Entry mp = (Map.Entry)ip.next();
System.out.println(mp.getKey() + " " +mp.getValue());
}
// practise purpose
HashMap hm = new HashMap();
hm.put(1, "Selenium");
hm.put(2, "QTP");
/
while(it.hasNext()){
Map.Entry mp = (Map.Entry)it.next();
//System.out.println(mp.getKey() +" "+ mp.getValue());
}
//practise purpose
HashMap hm3 = new HashMap();
hm3.put(1, "Santosh");
hm3.put(2, "kumar");
System.out.println("==="+hm3.get(1)+"===");
Set hs3 = hm3.entrySet();
Iterator it3 = hs3.iterator();
while(it3.hasNext()){
Map.Entry mp3 = (Map.Entry)it3.next();
//System.out.println(mp3.getKey() +" "+mp3.getValue());
}
}
}
HashSet:
public class CollectionsHashSet {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashSet obj = new HashSet();
obj.add(10);
obj.add(20);
obj.add(30);
obj.add(30);
obj.add(30);
System.out.println(obj);
System.out.println(obj.size());
//which contains same features what we have in ArrayList but it dont have the obj.get(indexval)
HashSet hss = new HashSet();
hss.add("Santosh");
hss.add("kumar");
Iterator it = hss.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
}
public class CollectionsHashMap {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashMap
HashMap
hs.put(3, "Gaddam");
hs.put(1, "Santosh");
hs.put(2, "kumar");
System.out.println(hs);
System.out.println("===");
hs.remove(2);
System.out.println(hs);
System.out.println("===");
hs.put(3, "Gaddams");
hs.put(4, "");
hs.put(5, "");
hs.put(null, "its me null key");
hs.put(null, "its me null keys");
System.out.println(hs);
Set hp = hs.entrySet();
Iterator ip = hp.iterator();
while(ip.hasNext()) {
Map.Entry mp = (Map.Entry)ip.next();
System.out.println(mp.getKey() + " " +mp.getValue());
}
// practise purpose
HashMap
hm.put(1, "Selenium");
hm.put(2, "QTP");
/
while(it.hasNext()){
Map.Entry
//System.out.println(mp.getKey() +" "+ mp.getValue());
}
//practise purpose
HashMap
hm3.put(1, "Santosh");
hm3.put(2, "kumar");
System.out.println("==="+hm3.get(1)+"===");
Set hs3 = hm3.entrySet();
Iterator it3 = hs3.iterator();
while(it3.hasNext()){
Map.Entry mp3 = (Map.Entry)it3.next();
//System.out.println(mp3.getKey() +" "+mp3.getValue());
}
}
}
HashSet:
public class CollectionsHashSet {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashSet
obj.add(10);
obj.add(20);
obj.add(30);
obj.add(30);
obj.add(30);
System.out.println(obj);
System.out.println(obj.size());
//which contains same features what we have in ArrayList but it dont have the obj.get(indexval)
HashSet
hss.add("Santosh");
hss.add("kumar");
Iterator it = hss.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
}
LinkedList:
public class CollectionsLinkedList {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList al=new LinkedList();
al.add("Ravi");
al.add("Vijay");
al.add("Ravi");
al.add("Ajay");
Iterator itr=al.iterator();
for(int i=0;i
System.out.println(al.get(i));
}
System.out.println("Before remove: " + al.get(2));
al.remove(2);
System.out.println("After remove: " + al.get(2));
// while(itr.hasNext()){
// System.out.println(itr.next());
//}
}
}
DBConnection:
public class DBConnection {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Class.forName("oracle.jdbc.driver.OracleDriver");
String host = "md1npdlnxdb08";
String port = "1521";
//Connection con=DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/demo", "root", "root");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@"+ host + ":" + port + ":tpo18pa", "WWF_2016_19_18PROP", "WWF_2016_19_18PROP");
Statement stm = con.createStatement();
ResultSet res = stm.executeQuery("select * from md_column_info where schema_name = 'WWF_2016_19_18PROP' and table_name='DN_TARGET' and column_name = 'OWNER'");
res.next();
}
}
GRID:
public class GridEx {
@Test
void grid() throws MalformedURLException{
DesiredCapabilities dc = new DesiredCapabilities().chrome();
dc.setBrowserName("chrome");
//dc.setCapability("marionatte", false);
//ChromeOptions opt = new ChromeOptions();
//opt.merge(dc);
dc.setPlatform(Platform.XP);
System.out.println(1);
//System.setProperty("webdriver.chrome.driver", "C:\\Automation\\Selenium\\drivers\\chromedriver_win32\\chromedriver.exe");
WebDriver driver;
System.out.println(2);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);
System.out.println(3);
driver.get("https://www.google.com/");
}
private DesiredCapabilities DesiredCapabilities() {
// TODO Auto-generated method stub
return null;
}
}
Comments
Post a Comment