go to http://oracle.in.th
Showing posts with label ice. Show all posts
Showing posts with label ice. Show all posts

Friday, July 9, 2010

Oracle Database Vault

Oracle Database Vault คืออะไร ? ในบทความวันนี้ ผมจะมาอธิบายข้อดีคร่าว ๆ ของการใช้เจ้าตัวนี้ ให้ทุกท่านได้อ่านกันนะครับ

Oracle Database Vault
คือส่วนหนึ่งของ database security ครับ โดยจะทำหน้าจำกัด user ผู้เข้าใช้ database ให้สามารถเข้าได้เฉพาะ user ที่ได้รับอนุญาติหรือเป็น DBA นั่นเองครับ ทั้งนี้เพื่อความปลอดภัยของ application ต่าง ๆ ที่ต้องการ security โดยมีหลักการ security ตามข้อบังคับต่าง ๆ เช่น Sarbanes-Oxley, Payment Card Industry (PCI) Data Security Standard (DSS), Health Insurance Portability and Accountability Act (HIPAA)และ อื่น ๆ ที่เกี่ยวข้องกับ security ใน data integrity และ data privacy โดย Oracle Database Vault จะทำการป้องกันการเข้าใช้ database ตาม environtment ต่างๆที่ต้องการ เช่น วันเวลาที่เข้าใช้, IP Address ของผู้เข้าใช้, ชื่อเข้า application ที่เข้ามาใช้ และการ authentication user ต่าง ๆ

โดยการใช้ Oracle Database Vault มีข้อดีดังนี้ครับ
  • Pro-actively safeguard application data stored in the Oracle database คือการป้องกันไม่ให้ผู้ใช้ที่ไม่ผ่านการ authentication เข้ามาใช้ข้อมูลได้
  • Address regulatory requirements คือการแบ่งความรับชอบตามหน้าที่ของ user
  • Restrict ad-hoc access to application data เป็นการป้องกันการใช้ application ที่ไม่ได้รับอนุญาติให้เข้าใช้ ด้วย multi-factor policies
  • Deploy with confidence สามารถติดตั้งได้กับ Oracle E-Business Suite, Oracle PeopleSoft, และ Oracle Siebel CRM
  • Realms เป็นการรวม schemas, object และ role ต่างๆที่ต้องการให้มี secure ไว้ด้วยกัน และกำหนดสิทธิ์ให้เฉพาะบาง user หรือ role มีสิทธิ์เข้าถึงข้อมูลเหล่านั้นได้
  • Command Rules เป็นการกำหนดให้ user สามารถ execute คำสั่งได้บางคำสั่ง
  • Factors เป็นการกำหนดการเข้าถึงข้อมูลโดยใช้ factor ซึ่งจะเก็บค่าต่างๆเช่น user location, database IP address หรือ user's session
  • Rule Sets คือ rule หรือกลุ่มของ rule ที่ใช้ร่วมกับ realms, command rule, factor และ secure application role
  • Secure Application Role เป็น special role ที่สามารถใช้ร่วมกับ rule set ได้
Credit by Ice, Yong

อ้างอิง
ข้อเขียนนี้ช่วยฉัน:  

Thursday, June 17, 2010

การ recovery PFILE และ SPFILE

บทความนี้ ผมขอเอาใจ DBA ทุกท่านโดยเฉพาะเลย สมมุติว่าถ้า DBA เผลอทำ parameter file หาย และ shutdown instance ไปแล้วด้วย, แถมยังไม่เคยมีการ backup ไว้ก่อนเลย, DBA สามารถแก้ไขอย่างไรได้บ้าง ? โดยปกติแล้ว ถ้าเกิดเราทำ file ใด ๆ ในเครื่องคอมหาย การจะกู้คืนกลับมาเราจะใช้การ recovery, ฉะนั้น เรามาดู วิธีการ recovery PFILE และ SPFILE ที่ไม่ได้มีการ backup ไว้กันเลยดีกว่า

ผมได้ทดสอบทำดู เลยจะขอแจงแจงรายละเอียดเป็นขั้นตอนต่อไปนี้ครับ

1. ทำการ shutdown instance และลบไฟล์ทั้ง 2 file นะครับ คือ PFILE และ SPFILE โดย
PFILE จะอยู่ที่ Path /oracle/admin/orcl/pfile
SPFILE จะอยู่ที่ Path /oracle/db11201/dbs

2. ไปเปิด alert log เพื่อดู parameter โดย alert log จะอยู่ที่ Path
/oracle/diag/rdbms/orcl/orcl/trace
โดยมีชื่อไฟล์ว่า alert_orcl.log

3. ทำการ copy ในส่วนนี้ของไฟล์ alert log มานะครับ
processes                = 150
  memory_target            = 812M
  control_files            = "/oracle/oradata/orcl/control01.ctl"
  control_files            = "/oracle/flash_recovery_area/orcl/control02.ctl"
  db_block_size            = 8192
  compatible               = "11.2.0.0.0"
  db_recovery_file_dest    = "/oracle/flash_recovery_area"
  db_recovery_file_dest_size= 3852M
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = "co.th"
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
  audit_file_dest          = "/oracle/admin/orcl/adump"
  audit_trail              = "DB"
  db_name                  = "orcl"
  open_cursors             = 300
  diagnostic_dest          = "/oracle"
4. ทำการสร้าง PFILE ชื่อ initorcl.ora ไว้ที่ Path /oracle/db11201/dbs โดยนำ content ของ alert log ที่ copy มาใส่ลงไปในไฟล์

5. เข้า sqlplus ด้วย user sys และทำการ start instance
$ sqlplus /nolog
sql> conn / as sysdba
sql> startup

6. ทำการสร้าง SPFILE จาก PFILE ไปไว้ที่ Path /oracle/db11201/dbs ด้วยคำสั่งต่อไปนี้
sql> create spfile='spfileorcl.ora'
       from pfile='/oracle/db11201/dbs/initorcl.ora';
7. เราจะได้ spfile ที่ชื่อ spfileorcl.ora มานะครับ

8. ทดสอบ startup instance อีกครั้ง พบว่าสามารถ start ได้ครับ
SQL> startup
ORACLE instance started.

Total System Global Area  849530880 bytes
Fixed Size                  1339824 bytes
Variable Size             499125840 bytes
Database Buffers          343932928 bytes
Redo Buffers                5132288 bytes
Database mounted.
Database opened.
SQL> 

เท่านี้เราก็สามารถนำ PFILE และ SPFILE กลับมาได้เหมือนเดิมแล้วครับ :)

Credit by Ice
ข้อเขียนนี้ช่วยฉัน:  

Tuesday, June 15, 2010

มารู้จักกับ Oracle interMedia กันดีกว่า

Oracle interMedia เป็น feature ที่ทำให้ Oracle Database สามารถที่จะทำการเก็บ บริหารจัด หรือกู้คืนข้อมูลประเภท image, audio, video หรือ media data อื่นๆ โดย Oracle interMedia เพิ่ม reliacility, availability และ data management ในด้านของ multimedia ให้กับ Oracle Database ที่ multimedia เป็นเนื้อหาหรือส่วนต่างๆของ internet, e-commerce และ media-rich application

แต่ Oracle interMedia ไม่ได้ทำการควบคุม media capture หรือ output ของ device เนื่องจากส้วนนี้เป็นหน้าที่ของ application software

โดย Oracle interMedia ทำการบริหารจัดการกับ multimedia โดยรองรับสิ่งต่างๆเหล่านี้
  • การจัดเก็บและการกู้คืน
  • การบริหารจัดการกับ metadata ของ media และ application
  • สามารถที่จะรองรับได้หลาย format
  • สามารถ access ผ่านแบบปกติ และได้กับ web interface
  • ทำการ query ด้วยการใช้ความสัมพันธ์ของข้อมูล
  • ทำการ query ด้วย extracted metadata
  • ทำการ query ด้วยการใช้ media content ที่มี optional specialized indexing
Oracle interMedia รองรับ media content สำหรับ Oracle JDeveloper, Oracle Content Management SDK, Oracle Application Server Porta และ Oracle Partner ด้วย

ตัวอย่างการใช้งาน Oracle interMedia

1. ทำการ connect เข้า database ด้วย sqlplus และทำการ สร้าง table ที่ชื่อว่า "image_table" เพื่อใช้ในการเก็บรูป
connect hr/hr
create table image_table (id number primary key, image ordsys.ordimage);
2. ทำการสร้าง directory ที่เก็บรูปไว้โดย ตั้งให้ตรงกับ directory ที่เก็บรูปไว้อยู่ ด้วย user sys และทำการให้สิทธิในการอ่าน directory แก่ user hr
connect / as sysdba
create or replace directory imagedir as '/home/oracle/quickstart/';
grant read on directory imagedir to hr;
3. ใช้ user hr ในการสร้าง PL/SQL procedure ในการ import รูปเข้ามายัง table
create or replace procedure image_import(dest_id number, filename varchar2) is
img ordsys.ordimage;
ctx raw(64) := null;
begin
delete from image_table where id = dest_id;
insert into image_table (id,image)
values (dest_id, ordsys.ordimage.init())
returning image into img;

img.importFrom(ctx, 'file', 'IMAGEDIR', filename);
update image_table set image=img where id=dest_id;
end;
/
! ที่ IMAGEDIR จะต้องพิมพ์เป็นตัวใหญ่ทั้งหมด แม้ในตอนที่สร้าง directory ขึ้นมาจาพิมพ์ด้วยตัวพิมพ์เล็กก็ตาม

4. ทดลองเรียกใช้ procedure ที่สร้างขึ้นมา
call image_import(1,’book2.jpg’);
call image_import(2,’check.png’);
เสร็จแล้วรูปทั้งสองรูปจะถูกเพิ่มเข้าไปยัง table

5. ตรวจสอบรูปภาพด้วยคำสั่ง select ต่อไปนี้ โดยสามารถใช้ดูได้หลายคุณสมบัติของรูป แต่คำสั่งในตัวอย่างนี้จะเป็นการดูความกว้างความยาวของรูป
SQL> select id,t.image.getheight(),t.image.getwidth() from image t;

ID T.IMAGE.GETHEIGHT() T.IMAGE.GETWIDTH()
---------- ------------------- ------------------
1                 134                572
2                 464                667

ในลิ้งค์อ้างอิงยังมีตัวอย่างการใช้ Oracle interMedia อีก แต่ขอยกตัวอย่างมาเพียงเท่านี้ครับ

Credit by Ice

อ้างอิง
ข้อเขียนนี้ช่วยฉัน:  

Thursday, March 25, 2010

หนทางการเป็น Expert ด้วย Oracle Certificate: ตอน เริ่มแรกสู่ OCA (Part1)

เมื่อวันที่ 8 ที่ผ่านมา มีเพื่อน ๆ ที่เข้ามาชมบล็อคเรา ได้โพสคอมเม้นไว้ว่า....
"สวัสดีครับ ผมอยากทรายรายละเอียดเกี่ยวกับ Oracle DBA Certificate ครับ รบกวนผู้รู้ช่วยแนะนำผมที"
 

ขอมา...ผมก็จัดให้! วันนี้ผมเลยเอารายละเอียดของ Oracle DBA Certificate มาฝากกันครับ ซึ่ง Certificate หรือผมขอเรียกสั้นๆว่า Cert ตัวนี้เนี่ย ก็เหมือนกับ ใบที่รับรองที่บอกว่า ผู้ที่ได้ Cert นี้ ได้ผ่านการรับรองว่า เป็นผู้ที่สามารถใช้งาน Oracle ได้อย่างชำนาญระดับหนึ่ง โดยทาง Oracle Corporation เป็นผู้ออกใบรับรอง หรือประกาศนียบัตรตัวนี้ให้กับผู้ที่สอบผ่านนั่นเอง

 โดยทั่วไปแล้ว การจะได้ Cert ของ Oracle DBA นั้น จะมีอยู่หลายระดับ ซึ่งมีทั้งหมด 4 ตัว คือ
  1. Oracle Certified Associate (OCA)
  2. Oracle Certified Professional (OCP)
  3. Oracle Certified Master (OCM)
  4. Oracle Certified Master (OCE)
ซึ่งวันนี้ เรามาดูที่ตัวแรกกันก่อน นั่นคือ...Oracle Certified Associate (OCA)

Oracle Certified Associate (OCA) เป็น Certificate ในระดับแรกของ Orale Database Administrator หรือ DBA สำหรับผู้ที่สามารถสอบผ่าน OCA ได้แล้วนั้น จะได้รับการรับรองว่าบุคคลผู้นั้น มีทักษะขั้นพื้นฐานและสามารถทำงานในระดับพื้นฐานของ Oracle ได้ครับ และถ้าผู้ที่ต้องการสอบ Certificate ของ Oracle ในระดับ Oracle Certified Professional หรือ OCP ได้ จะต้องทำการสอบในระดับ OCA ให้ผ่านเสียก่อนครับ ซึ่งในเรื่องของ OCP และ Cert อื่นๆ ผมจะกล่าวในบทความหน้านะครับ

ในรายละเอียดของการสอบ ผู้ที่สอบจะต้องผ่านการสอบถึง 2 ครั้งด้วยกันคือ
  • ครั้งที่หนึ่ง จะมีการสอบให้เลือก 3 แบบ
1. Introduction to Oracle9i SQL
2. Oracle Database SQL Expert
3. Oracle Database 11g SQL Fundamentals I

สำหรับการสอบ ในแบบที่ 1 คือ Introduction to Oracle9i SQL จะมีเวลาในการสอบทั้งสิ้น 120 นาที จำนวนข้อสอบ 52 ข้อ โดยคะแนนระดับที่จะผ่านการสอบ ต้องไม่ต่ำกว่า 71% ซึ่งมีเนื้อหาในการสอบดังนี้
  1. Writing Basic SQL SElect Statement
  2. Restricting and Sorting Data
  3. Single-Row Function
  4. Displaying Data from Multiple Tables
  5. Aggregating Data using Group Function
  6. Subqueries
  7. Producing Readable Output with iSQL *Plus
  8. Manipulating Data
  9. Creating and Managing Tables
  10. Including Constrains
  11. Creating Views
  12. Creating Other Database Objects
สำหรับการสอบ ในแบบที่ 2 คือ Oracle Database SQL Expert มีเวลาในการสอบ 120 นาที จำนวนข้อสอบ 70 ข้อ คะแนนระดับที่จะผ่านการสอบ ต้องไม่ต่ำกว่า 66% โดยมีเนื้อหาในการสอบดังนี้
  1. Retrieving Data Using the SQL SELECT Statement
  2. Restricting and Sorting Data
  3. Using Single-Row Functions to Customize Output
  4. Reporting Aggregated Data Using the Group Functions
  5. Displaying Data from Multiple Tables
  6. Using Dubqueries to Solve Queries
  7. Using the Set Operators
  8. Manipulating Data
  9. Using DDL Statements to Create and Manage Tables
  10. Creating Other Schema Object
  11. Managing Objects with Data Dictionary Views
  12. Controlling User Access
  13. Managing Schema Objects
  14. Manipulating Large Data Sets
  15. Generating Reports by Grouping Releated Data
  16. Managing Data in Different Time Zones
  17. Retrieving Data Using Subqueries
  18. Hierachical Retrieval
  19. Regular Expressing Support
สำหรับการสอบ ในแบบที่ 3 คือ Oracle Database 11g SQL Fundamentals I มีเวลาในการสอบ 120 นาทีจำนวนข้อสอบ 70 ข้อ คะแนนระดับที่จะผ่านการสอบ ต้องไม่ต่ำกว่า 60% โดยมีเนื้อหาในการสอบดังนี้
  1. Retrieving Data Using the SQL SELECT Statement
  2. Restricting and Sorting Data
  3. Using Single-Row Functions to Customize Output
  4. Using Conversion Functions and Conditional Expressions
  5. Reporting Aggregated Data Using th Group Functions
  6. Displaying Data from Multiple Tables
  7. Using Subqueries to Solve Queries
  8. Using the Set Operators
  9. Manipulating Data
  10. Using DDL Statements to Create and Manage Tables
  11. Creating Other Schema Objects

  • ครั้งที่ 2 ผู้สอบทุกคนจะต้องสอบแบบเดียวกันคือ Oracle Database 11g: Administration I
มีเวลาในการสอบ 90 นาที จำนวนข้อสอบ 70 ข้อ คะแนนระดับที่จะผ่านการสอบ ไม่ต่ำกว่า 66% โดยมีเนื้อหาในการสอบดังนี้
  1. Exploring the Oracle Database Architecture
  2. Preparing the Database Environment
  3. Creating an Oracle Database
  4. Managing the Oracle Instance
  5. Configuring the Oracle Network Environment
  6. Managing Database Storage Structures
  7. Managing DAta and Concurrency
  8. Managing Undo Data
  9. Implementing Oracle Database Security
  10. DAtabase Maintenance
  11. Performance Management
  12. Intelligent Infrastructure Enhancements
  13. Backup and Recovery Concepts
  14. Performing Database Backups
  15. Performing Database Recovery
  16. Moving Data
ผู้สอบสามารถเตรียมตัวในการสอบโดยการไปทดลองทำข้อสอบได้ที่นี่ แต่จะต้องเสียเงินครับ
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=208

สำหรับราคาค่าสอบแต่ละ แบบนั้นมีดังต่อไปนี้
1. Introduction to Oracle9i SQL US$ 125 หรือประมาณ 3875 บาท
2. Oracle Database SQL Expert US$ 195 หรือประมาณ 6045 บาท
3. Oracle Database 11g SQL Fundamentals I US$ 125 หรือประมาณ 3875 บาท
และ
Oracle Database 11g: Administration I US$ 195 หรือประมาณ 6045 บาท

สถานที่ในการสอบ ผู้สอบสามารถเข้าไป ลงทะเบียน ออนไลน์เพื่อเข้าสอบได้จากเว็บไซต์นี้ครับ
http://www.pearsonvue.com/oracle/

สำหรับคนที่จะเตรียตัวไปสอบ Cert ผมขอเป็นกำลังใจให้นะครับ
คราวหน้า ผมจะมาพูดถึงอีก 3 ตัวที่เหลือนะครับ... โชคดีครับ

Credit by Ice

อ้างอิง
ข้อเขียนนี้ช่วยฉัน:  

Thursday, November 19, 2009

การใช้งาน Google Contact Data API

Google มี API ให้เราสามารถนำมาใช้ในการติดต่อกับ Application ต่างๆของ Google ได้ เช่น Google Contact, Google Calendar การใช้ Contact Data API ทำได้ไม่อยาก โดยสามารถทำตามได้จากวิธีการดังนี้

1. ตรวจสอบว่าในเครื่องมีการติดตั้ง Eclipse และ Java Compiler ไว้เรียบร้อยแล้ว

2. Google Contact จะสามารถดึงข้อมูลจาก Google Account โดยที่จะต้องมี Account ของ Google ก่อน

3. จากนั้นให้ดาวน์โหลด Java Client Library จาก http://code.google.com/p/gdata-java-client/ ให้ดาวน์โหลดไฟล์ ชื่อ "gdata-samples.java-1.39.0.zip" มาทำการแตกไฟล์ไว้ใน "/eclipse/gdata"

4. จากนั้นให้ทดสอบการใช้ API โดยการทดลองรันโปรแกรมตัวอย่าง จาก "data/java/sample/contacts/ContactsExample.java"

5. โดยการ Compile โปรแกรมตัวอย่างจำเป็นต้อง import library ที่จำเป็นดังต่อไปนี้
import com.google.gdata.client.*;

import com.google.gdata.client.contacts.*;

import com.google.gdata.data.*;

import com.google.gdata.data.contacts.*;

import com.google.gdata.data.extensions.*;

import com.google.gdata.util.*;

import java.io.IOException;

import java.net.URL;
6. หลังจากทดสอบด้วยโปรแกรมตัวอย่างแล้ว ต่อไปจะเป็นขั้นตอนการใช้ Contact API ในขั้นตอนแรกเราจะต้องทำการเซ็ต
ContactsService myService = new ContactsService("exampleCo-exampleApp-1");

myService.setUserCredentials("your_account@gmail.com", "password");
7. ต่อไปเป็นการจัดการกับ Google Contact ที่สามารถทำได้ คือ Add New Contact, Update Contact และการ Delete Contact อันดับแรกคือ การ Add new Contact สามารถทำตามจาก source code ต่อไปนี้
public static ContactEntry createContact(ContactsService myService,

String fullName, String givenName, String familyName, String notes)

throws ServiceException, IOException {

// Create the entry to insert

ContactEntry contact = new ContactEntry();

Name name = new Name();

final String NO_YOMI = null;

 name.setFullName(new FullName(fullName, NO_YOMI));

 name.setGivenName(new GivenName(givenName, NO_YOMI));

name.setFamilyName(new FamilyName(familyName, NO_YOMI))

contact.setName(name);

contact.setContent(new PlainTextConstruct(notes));

 

Email primaryMail = new Email();

primaryMail.setAddress("liz@gmail.com");

primaryMail.setRel("http://schemas.google.com/g/2005#home");

 primaryMail.setPrimary(true);

contact.addEmailAddress(primaryMail);

 

Email secondaryMail = new Email();

secondaryMail.setAddress("liz@example.com");

 secondaryMail.setRel("http://schemas.google.com/g/2005#work");

secondaryMail.setPrimary(false);

contact.addEmailAddress(secondaryMail);

 

ExtendedProperty favouriteFlower = new ExtendedProperty();

favouriteFlower.setName("favourite flower");

favouriteFlower.setValue("daisy");

 contact.addExtendedProperty(favouriteFlower);

 

ExtendedProperty sportsProperty = new ExtendedProperty();

sportsProperty.setName("sports");

XmlBlob sportKinds = new XmlBlob();

sportKinds.setBlob(new String(""));

sportsProperty.setXmlBlob(sportKinds);

contact.addExtendedProperty(sportsProperty);

 

// Ask the service to insert the new entry

URL postUrl = new URL("http://www.google.com/m8/feeds/contacts/liz@gmail.com/full");

return myService.insert(postUrl, contact);

}
8. ต่อไปคือการ Update Contact โดยการที่จะ Update Contact นั้นจำเป็นที่จะต้องเรียก Contact ทั้งหมดออกมาเพื่อนที่จะรู้ว่าจะสามารถ Update Contact ใดได้บ้าง โดยการเรียก Contact ทั้งหมดออกมาสามารถทำได้จากการใช้ source code ดังต่อไปนี้
public static void printAllContacts(ContactsService myService)

throws ServiceException, IOException {

// Request the feed

URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/liz@gmail.com/full");

ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);

// Print the results

System.out.println(resultFeed.getTitle().getPlainText());

for (int i = 0; i < resultFeed.getEntries().size(); i++) {

ContactEntry entry = resultFeed.getEntries().get(i);

if (entry.hasName()) {

Name name = entry.getName();

if (name.hasFullName()) {

String fullNameToDisplay = name.getFullName().getValue();

        if (name.getFullName().hasYomi()) {

          fullNameToDisplay += " (" + name.getFullName().getYomi() + ")";

        }

        System.out.println("\t\t" + fullNameToDisplay);

      } else {

        System.out.println("\t\t (no full name found)");

      }

      if (name.hasNamePrefix()) {

        System.out.println("\t\t" + name.getNamePrefix().getValue());

      } else {

        System.out.println("\t\t (no name prefix found)");

      }

      if (name.hasGivenName()) {

        String givenNameToDisplay = name.getGivenName().getValue();

        if (name.getGivenName().hasYomi()) {

          givenNameToDisplay += " (" + name.getGivenName().getYomi() + ")";

        }

        System.out.println("\t\t" + givenNameToDisplay);

      } else {

        System.out.println("\t\t (no given name found)");

      }

      if (name.hasAdditionalName()) {

        String additionalNameToDisplay = name.getAdditionalName().getValue();

        if (name.getAdditionalName().hasYomi()) {

          additionalNameToDisplay += " (" + name.getAdditionalName().getYomi() + ")";

        }

        System.out.println("\t\t" + additionalNameToDisplay);

      } else {

        System.out.println("\t\t (no additional name found)");

      }

      if (name.hasFamilyName()) {

        String familyNameToDisplay = name.getFamilyName().getValue();

        if (name.getFamilyName().hasYomi()) {

         familyNameToDisplay += " (" + name.getFamilyName().getYomi() + ")";

        }

        System.out.println("\t\t" + familyNameToDisplay);

      } else {

        System.out.println("\t\t (no family name found)");

      }

      if (name.hasNameSuffix()) {

        System.out.println("\t\t" + name.getNameSuffix().getValue());

      } else {

        System.out.println("\t\t (no name suffix found)");

      }

    } else {

      System.out.println("\t (no name found)");

    }

 

    System.out.println("Email addresses:");

    for (Email email : entry.getEmailAddresses()) {

      System.out.print(" " + email.getAddress());

      if (email.getRel() != null) {

        System.out.print(" rel:" + email.getRel());

      }

      if (email.getLabel() != null) {

        System.out.print(" label:" + email.getLabel());

      }

      if (email.getPrimary()) {

        System.out.print(" (primary) ");

      }

      System.out.print("\n");

    }

 

    System.out.println("IM addresses:");

    for (Im im : entry.getImAddresses()) {

      System.out.print(" " + im.getAddress());

      if (im.getLabel() != null) {

        System.out.print(" label:" + im.getLabel());

      }

      if (im.getRel() != null) {

        System.out.print(" rel:" + im.getRel());

      }

      if (im.getProtocol() != null) {

        System.out.print(" protocol:" + im.getProtocol());

      }

      if (im.getPrimary()) {

        System.out.print(" (primary) ");

      }

      System.out.print("\n");

    }

 

    System.out.println("Groups:");

    for (GroupMembershipInfo group : entry.getGroupMembershipInfos()) {      

      String groupHref = group.getHref();

      System.out.println("  Id: " + groupHref);

    }

 

    System.out.println("Extended Properties:");

    for (ExtendedProperty property : entry.getExtendedProperties()) {

      if (property.getValue() != null) {

        System.out.println("  " + property.getName() + "(value) = " + 

            property.getValue());

      } else if (property.getXmlBlob() != null) {

        System.out.println("  " + property.getName() + "(xmlBlob)= " + 

            property.getXmlBlob().getBlob());

     }

    }

 

    String photoLink = entry.getContactPhotoLink().getHref();

    System.out.println("Photo Link: " + photoLink);

 

    if (photoLink.getEtag() != null) {

      System.out.println("Contact Photo's ETag: " + photoLink.getEtag());

    }

 

    System.out.println("Contact's ETag: " + entry.getEtag());

  }

}
9. หลังจากที่รับทุก Contact มาแล้วจากนั้นจำเป็นการ Update Contact ที่ต้องการโดยใช้ Source code ต่อไปนี้ โดยในตัวอย่างนี้จะเป็นการ Update เฉพาะ ชื่อของ Contact นั้นเท่านั้น
public static ContactEntry updateContactName(

    ContactsService myService, ContactEntry entryToUpdate, String newName)

    throws ServiceException, IOException {

  entryToUpdate.setTitle(new PlainTextConstruct(newName));

  URL editUrl = new URL(entryToUpdate.getEditLink().getHref());

  return myService.update(editUrl, entryToUpdate);

}
10. และสุดท้ายคือการลบ Contact ซึ่งการจะลบ Contact จะต้องรู้ว่าต้องการลบ Contact ใด แล้วจึงทำการลบ Contact ออกจาก Account โดยใช้ Source Code ดังต่อไปนี้
public static void deleteContact(ContactEntry entryToDelete)

    throws ServiceException, IOException {

 entryToDelete.delete();

}
ข้อเขียนนี้ช่วยฉัน:  

Friday, November 6, 2009

การติดตั้ง Google App Engine และ Google Plugin สำหรับ Eclipse

1. เริ่มต้นด้วยการดาวน์โหลด "Java SE Development Kit (JDK)" และติดตั้งลงในเครื่อง โดย Google App Engine จะรองรับกับ Java 5 และ Java 6 เท่านั้น

2. จากนั้นให้ทำการดาวน์โหลดโปรแกรม Eclipse จาก "http://www.eclipse.org/" และติดตั้งลงในเครื่อง

3. ดาวน์โหลด Google Plugin for Eclipse โดยจะมี Plugin สำหรับ Eclipse อยู่ 3 เวอร์ชั่น คือ 3.3, 3.4 และ 3.5 โดยสามารถดาวน์โหลด Plugin สำหรับเวอร์ชั่นต่างๆ จากลิงค์ด้วยล่าง

- The Google Plugin for Eclipse, for Eclipse 3.3 (Europa):

http://dl.google.com/eclipse/plugin/3.3

- The Google Plugin for Eclipse, for Eclipse 3.4 (Ganymade):

http://dl.google.com/eclipse/plugin/3.4

- The Google Plugin for Eclipse, for Eclipse 3.5 (Galileo):

http://dl.google.com/eclipse/plugin/3.5

4. ทำการติดตั้ง App Engine Java SDK โดยใช้ โปรแกรม Eclipse โดยไปที่ เมนู Help > Install New Software
Step 4 - Install

5. ในช่อง Work with ให้ใส่ location สำหรับเวอร์ชั่น 3.5 ให้ใส่ “http://dl.google.com/eclipse/plugin/3.5” ดังรูป

Step 5 - Add location

6. จากนั้นให้ Enable Check Box ที่ Plugin และ SDKs จากนั้น Click Next รอจนโปรแกรมทำการดาวน์โหลดและติดตั้งจนเสร็จแล้ว Click Finish

Step 6 - Enable Plugin Check Box

อ้างอิง
ข้อเขียนนี้ช่วยฉัน: