package com.Wblower.db;
import java.util.Hashtable; import java.util.Vector;
import org.garret.perst.Iterator; import org.garret.perst.Key;
public class ContactlistdatabaseQueries { public static Vector ContactDBVec = new Vector(); public static Hashtable ContactDBhash = new Hashtable();
public static void insertSingleContactlist(
Contactlistdatabasetable Contactlist) {
Root root = (Root) DataBaseConnectivity.db.getRoot();
root.Contactlistdatabasetable.put(new Key(""), Contactlist);
DataBaseConnectivity.db.commit();
}
public static void insertVectorContactlist(Vector ContactlistVector) {
System.out.println("Root set");
Root root = (Root) DataBaseConnectivity.db.getRoot();
int length = ContactlistVector.size();
for (int i = 0; i < length; i++) {
Contactlistdatabasetable Contactlist = (Contactlistdatabasetable) ContactlistVector
.elementAt(i);
root.Contactlistdatabasetable.put(new Key(""), Contactlist);
System.out.println(" insert single Contactlist --- "
+ Contactlist.feedtype + ", " + Contactlist.event + ", "
+ Contactlist.firstname + "," + Contactlist.lastname + ","
+ Contactlist.email + "," + Contactlist.email1 + ","
+ Contactlist.mobile + "," + Contactlist.mobile1 + ","
+ Contactlist.mobile2 + "," + Contactlist.web + ","
+ Contactlist.company + "," + Contactlist.address + ","
+ Contactlist.address1 + "," + Contactlist.timestamp);
}
// DataBaseConnectivity.db.commit();
}
public static void selectPrefixContactlist(String selectStr) {
Root root = (Root) DataBaseConnectivity.db.getRoot();
System.out.println("root created");
Iterator itr3 = root.Contactlistdatabasetable.prefixIterator(selectStr);
clearContactlist();
while (itr3.hasNext()) {
System.out
.println("----In select prefix Header data iterator----");
Contactlistdatabasetable Contactlist = (Contactlistdatabasetable) itr3
.next();
}
}
public static void selectWholeContactlist() {
Root root = (Root) DataBaseConnectivity.db.getRoot();
System.out.println("root created");
ContactDBhash.clear();
Iterator itr3 = root.Contactlistdatabasetable.iterator();
System.out.println("In itr3---------" + itr3);
System.out.println("In itr3 1111111---------" + itr3.hasNext());
clearContactlist();
int i = 0;
while (itr3.hasNext()) {
System.out
.println("@@@@@ in select whole Header data itr while loop @@@@@");
Contactlistdatabasetable Contactlist = (Contactlistdatabasetable) itr3
.next();
System.out.println(" insert single contact --- "
+ Contactlist.feedtype + ", " + Contactlist.event + ", "
+ Contactlist.firstname + "," + Contactlist.lastname + ","
+ Contactlist.email + "," + Contactlist.email1 + ","
+ Contactlist.mobile + "," + Contactlist.mobile1 + ","
+ Contactlist.mobile2 + "," + Contactlist.web + ","
+ Contactlist.company + "," + Contactlist.address + ","
+ Contactlist.address1 + "," + Contactlist.timestamp);
i++;
}
System.out.println("Number of rows in Contactlist==" + i);
}
public static void removePrefixContactlistDetails(
Contactlistdatabasetable Contactlist, String selectStr) {
Root root = (Root) DataBaseConnectivity.db.getRoot();
System.out.println("root created");
root.Contactlistdatabasetable.remove(new Key("", Contactlist));
System.out.println(" insert single Header data --- "
+ Contactlist.feedtype + ", " + Contactlist.event + ", "
+ Contactlist.firstname + "," + Contactlist.lastname + ","
+ Contactlist.email + "," + Contactlist.email1 + ","
+ Contactlist.mobile + "," + Contactlist.mobile1 + ","
+ Contactlist.mobile2 + "," + Contactlist.web + ","
+ Contactlist.company + "," + Contactlist.address + ","
+ Contactlist.address1 + "," + Contactlist.timestamp);
DataBaseConnectivity.db.commit();
}
public static void removeAllConatctlistDetails()
{
Root root = (Root) DataBaseConnectivity.db.getRoot();
System.out.println("root created");
root.Contactlistdatabasetable.clear();
DataBaseConnectivity.db.commit();
}
public static void updatePrefixContactlistDetails(String key, Contactlistdatabasetable Contactlist)
{
Root root = (Root) DataBaseConnectivity.db.getRoot();
root.Contactlistdatabasetable.set(new Key(key), Contactlist);
DataBaseConnectivity.db.commit();
}
public static Vector getContactData()
{
return ContactDBVec;
}
private static void clearContactlist() {
// TODO Auto-generated method stub
}
}
this is were i am able to fetch the data of a paticular class