隨筆-124  評論-194  文章-0  trackbacks-0
           
               摘要: 講了SED的用法,特別是換行c\命令,以及多行替換。  閱讀全文
          posted @ 2009-09-01 10:12 我愛佳娃 閱讀(3975) | 評論 (1)編輯 收藏
          這里有個帖子論證HIBERNATE在批量插入時性能下降,以及一些解決方式。

          其核心在于批量插入時,積攢一定量后就寫庫,并清除SESSION里的第一級緩存,以免后續插入操作受緩存查找而影響效率:

          if ( j % batchNum2 == 0 ) {//執行物理批量插入
                                             session.flush();
                                   session.clear();            

          }


          基于JPA的事務操作,SESSION不可見,此時,需要直接調用EntityManager的flush和clear。
          但EntityManager也是被封裝入JpaDaoSupport,實際的EntityManager對象也不容易取得。
          此時可以用其JpaTemplate成員的execute方法來實現這兩個操作:

                  getJpaTemplate().execute(new JpaCallback() {
                      
          public Object doInJpa(EntityManager em) throws PersistenceException {
                          em.flush();
                          em.clear();
                          
          return null;
                      }
                  }, 
          true);

          在我這里測試結果:
          沒有定期調用以上方法時,插入50個記錄要2秒,并且隨著記錄增多,時間越來越長。
          每插入50個調用以上方法后,插入50個記錄小于300毫秒,且不隨記錄個數線性增長。
          posted @ 2009-07-16 21:20 我愛佳娃 閱讀(6715) | 評論 (0)編輯 收藏
          Linux 運行的時候,是如何管理共享庫(*.so)的?在 Linux 下面,共享庫的尋找和加載是由 /lib/ld.so 實現的。 ld.so 在標準路經(/lib, /usr/lib) 中尋找應用程序用到的共享庫。

          但是,如果需要用到的共享庫在非標準路經,ld.so 怎么找到它呢?

          目前,Linux 通用的做法是將非標準路經加入 /etc/ld.so.conf,然后運行 ldconfig 生成 /etc/ld.so.cache。 ld.so 加載共享庫的時候,會從 ld.so.cache 查找。

          傳統上, Linux 的先輩 Unix 還有一個環境變量 - LD_LIBRARY_PATH 來處理非標準路經的共享庫。ld.so 加載共享庫的時候,也會查找這個變量所設置的路經。但是,有不少聲音主張要避免使用 LD_LIBRARY_PATH 變量,尤其是作為全局變量。這些聲音是:
          * LD_LIBRARY_PATH is not the answer - http://prefetch.net/articles/linkers.badldlibrary.html
          * Why LD_LIBRARY_PATH is bad - http://xahlee.org/UnixResource_dir/_/ldpath.html
          * LD_LIBRARY_PATH - just say no - http://blogs.sun.com/rie/date/20040710
          解決這一問題的另一方法是在編譯的時候通過 -R<path> 選項指定 run-time path。
          posted @ 2009-06-11 09:52 我愛佳娃 閱讀(837) | 評論 (0)編輯 收藏
               摘要: 今天搞了一天,JAVA調用一個PERL程序,得不得就退不出,千試萬試,LOG精細到逐行,知道在哪停住了,但打死不知道為什么。
          后來吃個飯都放棄了,居然又找到答案,要沒看到它,那真以為里面有鬼了。  閱讀全文
          posted @ 2009-05-15 21:04 我愛佳娃 閱讀(14250) | 評論 (4)編輯 收藏
          如需要,設置PROXY:
          export http_proxy=http://127.0.0.1:3128

          啟動,然后設置MIRROR,直接安裝:
          perl -MCPAN -e shell
          cpan> o conf urllist set http://www.perl87.cn/CPAN/
          cpan> install JSON
          posted @ 2009-05-12 16:31 我愛佳娃 閱讀(1198) | 評論 (0)編輯 收藏

          方法1:采用String的split,驗證代碼如下:
          import java.util.Arrays;
          public class TestSplit {
           public static void main(String[] args) {
            String orignString = new String("5,8,7,4,3,9,1");
            String[] testString = orignString.split(",");
            int[] test = { 0, 0, 0, 0, 0, 0, 0 };
            //String to int
            for (int i = 0; i < testString.length; i++) {
             test[i] = Integer.parseInt(testString[i]);
            }
            //sort
            Arrays.sort(test);
            //asc sort
            for (int j = 0; j < test.length; j++) {
             System.out.println(test[j]);
            }
            System.out.println("next ");
          //  desc
               for (int i = (test.length - 1); i >= 0; i--) {
                System.out.println(test[i]);
               }
           }
          }
          方法2:采用StringTokenizer

          import java.util.Arrays;
          import java.util.StringTokenizer;
          public class SplitStringTest {
           public static void main(String[] args) {
            String s = new String("5,8,7,4,3,9,1");
            int length = s.length();
            //split   s with ","
            StringTokenizer commaToker = new StringTokenizer(s, ",");
            String[] result = new String[commaToker.countTokens()];
            int k = 0;
            while (commaToker.hasMoreTokens()) {
             result[k] = commaToker.nextToken();
             k++;
            }
            int[] a = new int[result.length];
            for (int i = 0; i < result.length; i++) {
             a[i] = Integer.parseInt(result[i]);
            }
            //sort
            Arrays.sort(a);
            //asc sort
            for (int j = 0; j < result.length; j++) {
             System.out.println(a[j]);
            }
           }
          }
          posted @ 2009-04-24 13:07 我愛佳娃 閱讀(495) | 評論 (0)編輯 收藏
               摘要: mysqldump 是采用SQL級別的備份機制,它將數據表導成 SQL 腳本文件,在不同的 MySQL 版本之間升級時相對比較合適,這也是最常用的備份方法。  閱讀全文
          posted @ 2009-03-29 17:02 我愛佳娃 閱讀(2529) | 評論 (0)編輯 收藏
               摘要: 在EXT里如果定義類和擴展類  閱讀全文
          posted @ 2009-03-03 15:57 我愛佳娃 閱讀(1078) | 評論 (1)編輯 收藏
          update user set password = password ('xxxx') where user = "root";
          grant all privileges on *.* to root@'%' identified by 'xxxx';

          其它參數的例子:
          grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by '123';

            給來自10.163.225.87的用戶joe分配可對數據庫vtdc的employee表進行select,insert,update,delete,create,drop等操作的權限,并設定口令為123。


          要重啟一次MYSQL才能使本地用戶密碼生效:

          /usr/local/mysql/support-files/mysql.server restart


          posted @ 2009-02-12 14:31 我愛佳娃 閱讀(1660) | 評論 (0)編輯 收藏
          由于EXTJS是用XMLHTTP來LOAD的,所以在本地會看到一直LOADING的畫面。應該把它放到一個WEB服務器上,以HTTPD為例:

          編輯文件:
          /etc/httpd/conf.d/extjs.conf

          內容如下:
          Alias /extjs "/point/to/real/dir/ext/"

          <Directory 
          "/point/to/real/dir/ext/">
              Options Indexes
              AllowOverride AuthConfig Options
              Order allow
          ,deny
              Allow from all
          </Directory>

          重啟httpd:
          service httpd restart

          這樣訪問http://hostip/extjs/docs/index.html就能在本地看EXTJS的文檔了。


          注,經下面同學回復,有不用架設服務器的辦法,我搜了一下,供大家參考,本人未嘗試:
          http://www.aygfsteel.com/mengyuan760/archive/2008/04/21/194510.html

          posted @ 2009-02-05 11:52 我愛佳娃 閱讀(2448) | 評論 (2)編輯 收藏
          僅列出標題
          共13頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(19)

          隨筆分類(134)

          隨筆檔案(123)

          我的博客

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 552963
          • 排名 - 89

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 成都市| 池州市| 靖边县| 揭阳市| 崇义县| 昌吉市| 尼玛县| 含山县| 察哈| 郎溪县| 会同县| 镇安县| 崇信县| 江山市| 博兴县| 鱼台县| 洛南县| 遂溪县| 清新县| 济南市| 怀柔区| 绥滨县| 平阳县| 旅游| 拉萨市| 孟津县| 灵武市| 普宁市| 镇江市| 古浪县| 界首市| 瓮安县| 芦溪县| 通海县| 霍林郭勒市| 辽阳市| 沾益县| 海原县| 琼中| 西宁市| 乌苏市|