摘要: 講了SED的用法,特別是換行c\命令,以及多行替換。
閱讀全文
posted @
2009-09-01 10:12 我愛佳娃 閱讀(3972) |
評論 (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 我愛佳娃 閱讀(6713) |
評論 (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 我愛佳娃 閱讀(834) |
評論 (0) |
編輯 收藏
摘要: 今天搞了一天,JAVA調用一個PERL程序,得不得就退不出,千試萬試,LOG精細到逐行,知道在哪停住了,但打死不知道為什么。
后來吃個飯都放棄了,居然又找到答案,要沒看到它,那真以為里面有鬼了。
閱讀全文
posted @
2009-05-15 21:04 我愛佳娃 閱讀(14244) |
評論 (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 我愛佳娃 閱讀(1197) |
評論 (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 我愛佳娃 閱讀(490) |
評論 (0) |
編輯 收藏
摘要: mysqldump 是采用SQL級別的備份機制,它將數據表導成 SQL 腳本文件,在不同的 MySQL 版本之間升級時相對比較合適,這也是最常用的備份方法。
閱讀全文
posted @
2009-03-29 17:02 我愛佳娃 閱讀(2526) |
評論 (0) |
編輯 收藏
摘要: 在EXT里如果定義類和擴展類
閱讀全文
posted @
2009-03-03 15:57 我愛佳娃 閱讀(1077) |
評論 (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 我愛佳娃 閱讀(1656) |
評論 (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.tkk7.com/mengyuan760/archive/2008/04/21/194510.html
posted @
2009-02-05 11:52 我愛佳娃 閱讀(2446) |
評論 (2) |
編輯 收藏