CMyResultSetsExample.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Created: 2005-4-20 12:39:29
  3. * Last Modified: 2005-4-20/2005-4-20
  4. * Description:
  5. * class CMyResultSetsTest
  6. */
  7. package com.trs.example;
  8. import com.trs.TRSWCMBaseTest;
  9. import com.trs.infra.common.WCMException;
  10. import com.trs.infra.persistent.CMyResultSet;
  11. import com.trs.infra.persistent.CMyResultSets;
  12. /**
  13. * Title: TRS 内容协作平台(TRS WCM) <BR>
  14. * Description: <BR>
  15. * TODO <BR>
  16. * Copyright: Copyright (c) 2004-2005 TRS信息技术有限公司 <BR>
  17. * Company: TRS信息技术有限公司(www.trs.com.cn) <BR>
  18. *
  19. * @author TRS信息技术有限公司
  20. * @version 1.0
  21. */
  22. public class CMyResultSetsExample extends TRSWCMBaseTest {
  23. private static org.apache.log4j.Logger logger = org.apache.log4j.Logger
  24. .getLogger(CMyResultSetsExample.class);
  25. /*
  26. * Class under test for void open(String, String)
  27. */
  28. public void queryDocuments() throws WCMException {
  29. // 指定查询的SQL
  30. String sSQL = "select DocTitle,DocId from wcmdocument where docid<10010 and docid>10000";
  31. // 指定这次查询相关的SQL
  32. // 如果确定这次查询没有明确ID字段,系统支持将记录行号作为ID
  33. String sIdFieldName = "docid";
  34. // 发出查询获取集合
  35. CMyResultSets aMyResulteSets = new CMyResultSets();
  36. aMyResulteSets.open(sSQL, sIdFieldName);
  37. // 遍历输出结果
  38. logger.info("find [" + aMyResulteSets.size() + "] record!");
  39. for (int i = 0; i < aMyResulteSets.size(); i++) {
  40. CMyResultSet aObj = (CMyResultSet) aMyResulteSets.getAt(i);
  41. if (aObj == null)
  42. continue;
  43. logger.info("aObj.doctitle:" + aObj.getPropertyAsString("DocTitle"));
  44. logger.info("aObj.docid:" + aObj.getPropertyAsString("DocId"));
  45. }
  46. }
  47. }