Sunday, July 24, 2011

Derby JDBC client file

The Apache Derby JDBC driver is included inside the derbyclient.jar file that comes with the BIN or lib distribution of Derby.

Wednesday, July 20, 2011

ArrayList

import java.util.ArrayList;



public class Main {

/**
* @param args
*/
public static ArrayList merge(String[] words, String[] more) {
ArrayList sentence = new ArrayList();
for (String w : words) sentence.add(w);
for (String w : more) sentence.add(w);
return sentence;
}
public static void main(String[] args) {
String[] northAmerica=new String[5];
northAmerica[0]="USA";
northAmerica[2]="CANADA";
northAmerica[1]="Mexico";
northAmerica[3]="Panama";
northAmerica[4]="Haiti" ;

String[] southAmerica=new String[5];
southAmerica[0]="Brazil";
southAmerica[1]="Argentina";
southAmerica[2]="Colombia";
southAmerica[3]="Uruguay";
southAmerica[4]="Venezuela";
ArrayList americanContr=new ArrayList();
americanContr=merge(northAmerica, southAmerica);
System.out.println(americanContr);
}

}

HashTable

import java.util.HashMap;

/**
*
*/

/**
* @author Sajjad
*
*/
class Student
{
private int id;
private String name;
private String std;

public int getId() {
return id;
}

public Student(int id, String name, String std) {
this.id = id;
this.name = name;
this.std = std;
}

@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", std=" + std + "]";
}


}
public class hashTable {

/**
* @param args
*/
public static HashMap buildMap(Student[] students) {
HashMap map = new HashMap();
for (Student s : students) map.put(s.getId(), s);
return map;
}
public static void main(String[] args) {
Student[] students = new Student[5];
students[0]=new Student(1, "abdulla", "KG1");
students[1]=new Student(2, "Mohd", "KG2");
students[2]=new Student(3, "Harry", "2");
students[3]=new Student(4, "Saud", "KG1");
students[4]=new Student(5, "John", "KG2");

// TODO Auto-generated method stub
// for (Student s : students)
//{
// System.out.println(s);
//}
HashMap myMap = new HashMap();
myMap=buildMap(students);
System.out.println(myMap);

}

}

Friday, July 15, 2011

write log-in data in session - JSF

FacesContext context = FacesContext.getCurrentInstance();
HttpSession session =
(HttpSession)context.getExternalContext().getSession(true);

session.setAttribute("username", user);
session.setAttribute("password", pass);

Wednesday, July 13, 2011

change Run target in Jdeveloper

Project Properties->Run/Debug Profile Edit default profile->Launch Settings