2010-07-17 3 views
0

지난 3 일 동안 시도해 본 결과이 문제를 해결할 수 없었습니다.블랙 베리 데이터베이스에서 청취자 데이터를 가져 오는 중 오류가 발생했습니다.

저는 데이터를 저장하는 데 perstlite를 사용했습니다. 필요한 클래스에 대한 테이블과 쿼리를 만들었습니다.

이제 모바일 연락처를 청취하고 있으며 해당 클래스의 데이터 만 가져올 수 있지만 메인 클래스 또는 프로젝트의 어디서나 정보를 가져올 수는 없습니다. 수업. 아무도이 문제를 도와 줄 수 있습니까? "ContactlistdatabaseQueries.selectWholeContactlist();"

내가 u는 내가 선택한 내 문제

을 이해 바랍니다 내 프로그램

package com.Wblower.listeners; 



import java.util.Hashtable; 

import javax.microedition.pim.Contact; 
import javax.microedition.pim.PIMItem; 
import javax.microedition.pim.PIMList; 
import com.Wblower.db.ContactlistdatabaseQueries; 
import com.Wblower.db.Contactlistdatabasetable; 
import com.Wblower.db.DataBaseConnectivity; 
import com.Wblower.util.DateTimeUtil; 



import net.rim.blackberry.api.pdap.BlackBerryContact; 
import net.rim.blackberry.api.pdap.BlackBerryContactList; 
import net.rim.blackberry.api.pdap.PIMListListener; 

public class ContactListener implements PIMListListener { 

    BlackBerryContactList contactList; 
    DataBaseConnectivity dbconnectVity = new DataBaseConnectivity(); 

    public void itemAdded(PIMItem arg0) { 

     System.out.println("Item Added =="); 
     String firstname = "none"; 
     String lastname = "none"; 
     String mobile = "none"; 
     String mobile1 = "none"; 
     String mobile2 = "none"; 
     String email = "none"; 
     String email1 = "none"; 
     String web = "none"; 
     String company = "none"; 
     String address = "none"; 
     String address1 = "none"; 
     String name[] = { "" }; 
     String timeStamp = "none"; 

     PIMList contacts = arg0.getPIMList(); 
     Contact contact = (Contact) arg0; 

     if (contacts.isSupportedField(Contact.NAME)) { 

      try { 
       if (contact.countValues(Contact.NAME) > 0) 
        name = contact.getStringArray(Contact.NAME, 0); 
       if (name[Contact.NAME_GIVEN] != null) 
        firstname = name[Contact.NAME_GIVEN]; 
       System.out.println("FirstName= " + firstname); 
       if (name[Contact.NAME_FAMILY] != null) 
        lastname = name[Contact.NAME_FAMILY]; 
       System.out.println("LastName= " + lastname); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 

     } 
     if (contacts.isSupportedField(Contact.EMAIL)) { 
      try { 
       if (contact.countValues(Contact.EMAIL) > 0) 
        email = contact.getString(Contact.EMAIL, 0); 
       System.out.println("Email " + email); 

       if (contact.countValues(Contact.EMAIL) > 1) 
        email1 = contact.getString(Contact.EMAIL, 1); 
       System.out.println("Email " + email1); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.ORG)) { 

      try { 
       if (contact.countValues(Contact.ORG) > 0) 
        company = contact.getString(Contact.ORG, 0); 
       System.out.println("Company " + company); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.URL)) { 
      try { 
       if (contact.countValues(Contact.URL) > 0) 
        web = contact.getString(Contact.URL, 0); 
       System.out.println("web " + web); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 
     if (contacts.isSupportedField(Contact.TEL)) { 
      try { 
       if (contact.countValues(Contact.TEL) > 0) 
        mobile = contact.getString(Contact.TEL, 0); 
       System.out.println("Phone " + mobile); 

       if (contact.countValues(Contact.TEL) > 1) 
        mobile1 = contact.getString(Contact.TEL, 1); 
       System.out.println("Phone " + mobile1); 

       if (contact.countValues(Contact.TEL) > 2) 
        mobile2 = contact.getString(Contact.TEL, 2); 
       System.out.println("Phone " + mobile2); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
      if (contacts.isSupportedField(Contact.ADDR)) { 

       try { 
        address = ""; 
        String[] addressarr = contact.getStringArray(
          BlackBerryContact.ADDR, 0); 

        for (int i = 0; i < addressarr.length; i++) { 

         if (addressarr[i] != null) { 
          address = address + " " + addressarr[i]; 

         } 

        } 
        System.out.println("Address==" + address); 

        address1 = ""; 
        String[] addressar = contact.getStringArray(
          BlackBerryContact.ADDR, 1); 

        for (int i = 0; i < addressar.length; i++) { 
         if (addressar[i] != null) { 
          address1 = address1 + " " + addressar[i]; 

         } 

        } 
        System.out.println("Address==" + address1); 
       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       timeStamp = DateTimeUtil.timestamp(); 

       try { 

        System.out.println("Entering into the db"); 
        dbconnectVity.setDataBase(); 
        Contactlistdatabasetable Contactlist; 
        Contactlist = new Contactlistdatabasetable(
          "Contacts", "Add", firstname, lastname, mobile, 
          mobile1, mobile2, email, email1, web, company, 
          address, address1, timeStamp); 
        ContactlistdatabaseQueries.insertSingleContactlist(Contactlist); 
        ContactlistdatabaseQueries.selectWholeContactlist();   
       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       return; 

      } 

     } 

    } 

    public void itemRemoved(PIMItem arg0) { 
     System.out.println("Item Removed =="); 
     String firstname = "none"; 
     String lastname = "none"; 
     String mobile = "none"; 
     String mobile1 = "none"; 
     String mobile2 = "none"; 
     String email = "none"; 
     String email1 = "none"; 
     String web = "none"; 
     String company = "none"; 
     String address = "none"; 
     String address1 = "none"; 
     String name[] = { "" }; 
     String timeStamp = "none"; 

     PIMList contacts = arg0.getPIMList(); 
     Contact contact = (Contact) arg0; 

     if (contacts.isSupportedField(Contact.NAME)) { 

      try { 
       if (contact.countValues(Contact.NAME) > 0) 
        name = contact.getStringArray(Contact.NAME, 0); 
       if (name[Contact.NAME_GIVEN] != null) 
        firstname = name[Contact.NAME_GIVEN]; 
       System.out.println("FirstName= " + firstname); 
       if (name[Contact.NAME_FAMILY] != null) 
        lastname = name[Contact.NAME_FAMILY]; 
       System.out.println("LastName= " + lastname); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 

     } 
     if (contacts.isSupportedField(Contact.EMAIL)) { 
      try { 
       if (contact.countValues(Contact.EMAIL) > 0) 
        email = contact.getString(Contact.EMAIL, 0); 
       System.out.println("Email " + email); 

       if (contact.countValues(Contact.EMAIL) > 1) 
        email1 = contact.getString(Contact.EMAIL, 1); 
       System.out.println("Email " + email1); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.ORG)) { 

      try { 
       if (contact.countValues(Contact.ORG) > 0) 
        company = contact.getString(Contact.ORG, 0); 
       System.out.println("Company " + company); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.URL)) { 
      try { 
       if (contact.countValues(Contact.URL) > 0) 
        web = contact.getString(Contact.URL, 0); 
       System.out.println("web " + web); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 
     if (contacts.isSupportedField(Contact.TEL)) { 
      try { 
       if (contact.countValues(Contact.TEL) > 0) 
        mobile = contact.getString(Contact.TEL, 0); 
       System.out.println("Phone " + mobile); 

       if (contact.countValues(Contact.TEL) > 1) 
        mobile1 = contact.getString(Contact.TEL, 1); 
       System.out.println("Phone " + mobile1); 

       if (contact.countValues(Contact.TEL) > 2) 
        mobile2 = contact.getString(Contact.TEL, 2); 
       System.out.println("Phone " + mobile2); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
      if (contacts.isSupportedField(Contact.ADDR)) { 

       try { 
        address = ""; 
        String[] addressarr = contact.getStringArray(
          BlackBerryContact.ADDR, 0); 

        for (int i = 0; i < addressarr.length; i++) { 

         if (addressarr[i] != null) { 
          address = address + " " + addressarr[i]; 

         } 

        } 
        System.out.println("Address==" + address); 

        address1 = ""; 
        String[] addressar = contact.getStringArray(
          BlackBerryContact.ADDR, 1); 

        for (int i = 0; i < addressar.length; i++) { 

         if (addressar[i] != null) { 
          address1 = address1 + " " + addressar[i]; 

         } 

        } 
        System.out.println("Address==" + address1); 
       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       timeStamp = DateTimeUtil.timestamp(); 

       try { 
        System.out.println("Entering into the db"); 
        dbconnectVity.setDataBase(); 
        Contactlistdatabasetable Contactlist; 
        Contactlist = new Contactlistdatabasetable(
          "Contacts", "Delete", firstname, lastname, mobile, 
          mobile1, mobile2, email, email1, web, company, 
          address, address1, timeStamp); 
        ContactlistdatabaseQueries.insertSingleContactlist(Contactlist); 
        ContactlistdatabaseQueries.selectWholeContactlist(); 
       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       return; 
      } 
     } 

    } 

    public void itemUpdated(PIMItem arg0, PIMItem arg1) { 
     System.out.println("Item Updated =="); 
     String firstname = "none"; 
     String lastname = "none"; 
     String mobile = "none"; 
     String mobile1 = "none"; 
     String mobile2 = "none"; 
     String email = "none"; 
     String email1 = "none"; 
     String web = "none"; 
     String company = "none"; 
     String address = "none"; 
     String address1 = "none"; 
     String name[] = { "" }; 
     String timeStamp = "none"; 

     PIMList contacts = arg1.getPIMList(); 
     Contact contact = (Contact) arg1; 

     if (contacts.isSupportedField(Contact.NAME)) { 

      try { 
       if (contact.countValues(Contact.NAME) > 0) 
        name = contact.getStringArray(Contact.NAME, 0); 
       if (name[Contact.NAME_GIVEN] != null) 
        firstname = name[Contact.NAME_GIVEN]; 
       System.out.println("FirstName= " + firstname); 
       if (name[Contact.NAME_FAMILY] != null) 
        lastname = name[Contact.NAME_FAMILY]; 
       System.out.println("LastName= " + lastname); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 

     } 
     if (contacts.isSupportedField(Contact.EMAIL)) { 
      try { 
       if (contact.countValues(Contact.EMAIL) > 0) 
        email = contact.getString(Contact.EMAIL, 0); 
       System.out.println("Email " + email); 

       if (contact.countValues(Contact.EMAIL) > 1) 
        email1 = contact.getString(Contact.EMAIL, 1); 
       System.out.println("Email " + email1); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.ORG)) { 

      try { 
       if (contact.countValues(Contact.ORG) > 0) 
        company = contact.getString(Contact.ORG, 0); 
       System.out.println("Company " + company); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 

     if (contacts.isSupportedField(Contact.URL)) { 
      try { 
       if (contact.countValues(Contact.URL) > 0) 
        web = contact.getString(Contact.URL, 0); 
       System.out.println("web " + web); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
     } 
     if (contacts.isSupportedField(Contact.TEL)) { 
      try { 
       if (contact.countValues(Contact.TEL) > 0) 
        mobile = contact.getString(Contact.TEL, 0); 
       System.out.println("Phone " + mobile); 

       if (contact.countValues(Contact.TEL) > 1) 
        mobile1 = contact.getString(Contact.TEL, 1); 
       System.out.println("Phone " + mobile1); 

       if (contact.countValues(Contact.TEL) > 2) 
        mobile2 = contact.getString(Contact.TEL, 2); 
       System.out.println("Phone " + mobile2); 
      } catch (Exception e) { 
       System.out.println("Exception::" + e.getMessage()); 
      } 
      if (contacts.isSupportedField(Contact.ADDR)) { 

       try { 
        address = ""; 
        String[] addressarr = contact.getStringArray(
          BlackBerryContact.ADDR, 0); 

        for (int i = 0; i < addressarr.length; i++) { 

         if (addressarr[i] != null) { 
          address = address + " " + addressarr[i]; 

         } 

        } 
        System.out.println("Address==" + address); 
        address1 = ""; 
        String[] addressar = contact.getStringArray(
          BlackBerryContact.ADDR, 1); 

        for (int i = 0; i < addressar.length; i++) { 
         if (addressar[i] != null) { 
          address1 = address1 + " " + addressar[i]; 

         } 

        } 
        System.out.println("Address==" + address1); 
       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       timeStamp = DateTimeUtil.timestamp(); 

       try { 
        System.out.println("Entering into the db"); 
        dbconnectVity.setDataBase(); 
        Contactlistdatabasetable Contactlist; 
        Contactlist = new Contactlistdatabasetable(
          "Contacts", "Update", firstname, lastname, mobile, 
          mobile1, mobile2, email, email1, web, company, 
          address, address1, timeStamp); 
        ContactlistdatabaseQueries.insertSingleContactlist(Contactlist); 
        ContactlistdatabaseQueries.selectWholeContactlist(); 

       } catch (Exception e) { 
        System.out.println("Exception::" + e.getMessage()); 
       } 

       return; 
      } 
     } 
    } 
} 

입니다 모든 주 클래스에서이 메서드는 데이터베이스에서 데이터를 가져올 수 없습니다. 응답은 0입니다. 그러나 저장된 데이터의 값, 즉 삽입 된 행의 수를 가져와야합니다.

답변

0

내 문제는 아무것도하지만, 단지 문제에 사용 perstlite 되 잖아 데이터베이스, 을 변경하지만 지속적는 위의 문제

에 대한 하나 더 좋을 것 sloved 내가 가지고
관련 문제